diff --git a/web/pgadmin/tools/datagrid/static/js/datagrid.js b/web/pgadmin/tools/datagrid/static/js/datagrid.js
index c44fbb18..24a49ae8 100644
--- a/web/pgadmin/tools/datagrid/static/js/datagrid.js
+++ b/web/pgadmin/tools/datagrid/static/js/datagrid.js
@@ -1,34 +1,37 @@
 define('pgadmin.datagrid', [
-  'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'pgadmin.alertifyjs',
-  'sources/pgadmin', 'bundled_codemirror', 'sources/sqleditor_utils', 'wcdocker'
-], function(gettext, url_for, $, _, alertify, pgAdmin, codemirror, sqlEditorUtils) {
-    // Some scripts do export their object in the window only.
-    // Generally the one, which do no have AMD support.
-    var wcDocker = window.wcDocker,
-      pgBrowser = pgAdmin.Browser,
-      CodeMirror = codemirror.default;
-
-    /* Return back, this has been called more than once */
-    if (pgAdmin.DataGrid)
-      return pgAdmin.DataGrid;
-
-    pgAdmin.DataGrid = {
-      init: function() {
-        if (this.initialized)
-            return;
-        this.initialized = true;
-        this.title_index = 1;
-
-        this.spinner_el = '<div class="wcLoadingContainer">'+
-              '<div class="wcLoadingBackground"></div>'+
-                '<div class="wcLoadingIconContainer">'+
-                  '<i class="wcLoadingIcon fa fa-spinner fa-pulse"></i>'+
-                '</div>'+
-              '</div>';
-        // Define list of nodes on which view data option appears
-        var supported_nodes = [
-           'table', 'view', 'mview',
-           'foreign_table', 'catalog_object', 'partition'
+  'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
+  'pgadmin.alertifyjs', 'sources/pgadmin', 'bundled_codemirror',
+  'sources/sqleditor_utils', 'wcdocker',
+], function(
+  gettext, url_for, $, _, Alertify, pgAdmin, codemirror, sqlEditorUtils
+) {
+  // Some scripts do export their object in the window only.
+  // Generally the one, which do no have AMD support.
+  var wcDocker = window.wcDocker,
+    pgBrowser = pgAdmin.Browser,
+    CodeMirror = codemirror.default;
+
+  /* Return back, this has been called more than once */
+  if (pgAdmin.DataGrid)
+    return pgAdmin.DataGrid;
+
+  pgAdmin.DataGrid = {
+    init: function() {
+      if (this.initialized)
+        return;
+      this.initialized = true;
+      this.title_index = 1;
+
+      this.spinner_el = '<div class="wcLoadingContainer">' +
+        '<div class="wcLoadingBackground"></div>' +
+        '<div class="wcLoadingIconContainer">' +
+        '<i class="wcLoadingIcon fa fa-spinner fa-pulse"></i>' +
+        '</div>' +
+        '</div>';
+      // Define list of nodes on which view data option appears
+      var supported_nodes = [
+          'table', 'view', 'mview',
+          'foreign_table', 'catalog_object', 'partition',
         ],
 
         /* Enable/disable View data menu in tools based
@@ -37,8 +40,8 @@ define('pgadmin.datagrid', [
          * otherwise disabled.
          */
         view_menu_enabled = function(obj) {
-          if(!_.isUndefined(obj) && !_.isNull(obj))
-            return (_.indexOf(supported_nodes, obj._type) !== -1 ? true: false);
+          if (!_.isUndefined(obj) && !_.isNull(obj))
+            return (_.indexOf(supported_nodes, obj._type) !== -1 ? true : false);
           else
             return false;
         },
@@ -49,503 +52,546 @@ define('pgadmin.datagrid', [
          * otherwise enabled.
          */
         query_tool_menu_enabled = function(obj) {
-          if(!_.isUndefined(obj) && !_.isNull(obj)) {
-            if(_.indexOf(pgAdmin.unsupported_nodes, obj._type) == -1) {
+          if (!_.isUndefined(obj) && !_.isNull(obj)) {
+            if (_.indexOf(pgAdmin.unsupported_nodes, obj._type) == -1) {
               if (obj._type == 'database' && obj.allowConn)
                 return true;
-              else if(obj._type != 'database')
+              else if (obj._type != 'database')
                 return true;
               else
                 return false;
-             } else {
-                return false;
-             }
+            } else {
+              return false;
+            }
           } else {
             return false;
           }
         };
 
-        // Define the nodes on which the menus to be appear
-        var menus = [{
-          name: 'query_tool', module: this, applies: ['tools'],
-          callback: 'show_query_tool', enable: query_tool_menu_enabled,
-          priority: 1, label: gettext('Query Tool'),
-          icon: 'fa fa-bolt'
-        }];
-
-        // Create context menu
-        for (var idx = 0; idx < supported_nodes.length; idx++) {
-          menus.push({
-            name: 'view_all_rows_context_' + supported_nodes[idx],
-            node: supported_nodes[idx], module: this, data: {mnuid: 3},
-            applies: ['context', 'object'], callback: 'show_data_grid', enable: view_menu_enabled,
-            category: 'view_data', priority: 101, label: gettext('All Rows')
-          },{
-            name: 'view_first_100_rows_context_' + supported_nodes[idx],
-            node: supported_nodes[idx], module: this, data: {mnuid: 1},
-            applies: ['context', 'object'], callback: 'show_data_grid', enable: view_menu_enabled,
-            category: 'view_data', priority: 102, label: gettext('First 100 Rows')
-          },{
-            name: 'view_last_100_rows_context_' + supported_nodes[idx],
-            node: supported_nodes[idx], module: this, data: {mnuid: 2},
-            applies: ['context', 'object'], callback: 'show_data_grid', enable: view_menu_enabled,
-            category: 'view_data', priority: 103, label: gettext('Last 100 Rows')
-          },{
-            name: 'view_filtered_rows_context_' + supported_nodes[idx],
-            node: supported_nodes[idx], module: this, data: {mnuid: 4},
-            applies: ['context', 'object'], callback: 'show_filtered_row', enable: view_menu_enabled,
-            category: 'view_data', priority: 104, label: gettext('Filtered Rows...')
-         });
-        }
-
-        pgAdmin.Browser.add_menu_category('view_data', gettext('View/Edit Data'), 100, '');
-        pgAdmin.Browser.add_menus(menus);
-
-        // Creating a new pgAdmin.Browser frame to show the data.
-        var dataGridFrameType = new pgAdmin.Browser.Frame({
-          name: 'frm_datagrid',
-          showTitle: true,
-          isCloseable: true,
-          isPrivate: true,
-          url: 'about:blank'
+      // Define the nodes on which the menus to be appear
+      var menus = [{
+        name: 'query_tool',
+        module: this,
+        applies: ['tools'],
+        callback: 'show_query_tool',
+        enable: query_tool_menu_enabled,
+        priority: 1,
+        label: gettext('Query Tool'),
+        icon: 'fa fa-bolt',
+      }];
+
+      // Create context menu
+      for (var idx = 0; idx < supported_nodes.length; idx++) {
+        menus.push({
+          name: 'view_all_rows_context_' + supported_nodes[idx],
+          node: supported_nodes[idx],
+          module: this,
+          data: {
+            mnuid: 3,
+          },
+          applies: ['context', 'object'],
+          callback: 'show_data_grid',
+          enable: view_menu_enabled,
+          category: 'view_data',
+          priority: 101,
+          label: gettext('All Rows'),
+        }, {
+          name: 'view_first_100_rows_context_' + supported_nodes[idx],
+          node: supported_nodes[idx],
+          module: this,
+          data: {
+            mnuid: 1,
+          },
+          applies: ['context', 'object'],
+          callback: 'show_data_grid',
+          enable: view_menu_enabled,
+          category: 'view_data',
+          priority: 102,
+          label: gettext('First 100 Rows'),
+        }, {
+          name: 'view_last_100_rows_context_' + supported_nodes[idx],
+          node: supported_nodes[idx],
+          module: this,
+          data: {
+            mnuid: 2,
+          },
+          applies: ['context', 'object'],
+          callback: 'show_data_grid',
+          enable: view_menu_enabled,
+          category: 'view_data',
+          priority: 103,
+          label: gettext('Last 100 Rows'),
+        }, {
+          name: 'view_filtered_rows_context_' + supported_nodes[idx],
+          node: supported_nodes[idx],
+          module: this,
+          data: {
+            mnuid: 4,
+          },
+          applies: ['context', 'object'],
+          callback: 'show_filtered_row',
+          enable: view_menu_enabled,
+          category: 'view_data',
+          priority: 104,
+          label: gettext('Filtered Rows...'),
         });
+      }
 
-        // Load the newly created frame
-        dataGridFrameType.load(pgBrowser.docker);
-      },
-
-      // This is a callback function to show data when user click on menu item.
-      show_data_grid: function(data, i) {
-        var self = this,
-            d = pgAdmin.Browser.tree.itemData(i);
-        if (d === undefined) {
-          alertify.alert(
-            gettext('Data Grid Error'),
-            gettext('No object selected.')
-          );
-          return;
-        }
+      pgAdmin.Browser.add_menu_category('view_data', gettext('View/Edit Data'), 100, '');
+      pgAdmin.Browser.add_menus(menus);
+
+      // Creating a new pgAdmin.Browser frame to show the data.
+      var dataGridFrameType = new pgAdmin.Browser.Frame({
+        name: 'frm_datagrid',
+        showTitle: true,
+        isCloseable: true,
+        isPrivate: true,
+        url: 'about:blank',
+      });
+
+      // Load the newly created frame
+      dataGridFrameType.load(pgBrowser.docker);
+    },
+
+    // This is a callback function to show data when user click on menu item.
+    show_data_grid: function(data, i) {
+      var self = this,
+        d = pgAdmin.Browser.tree.itemData(i);
+      if (d === undefined) {
+        Alertify.alert(
+          gettext('Data Grid Error'),
+          gettext('No object selected.')
+        );
+        return;
+      }
 
-        // Get the parent data from the tree node hierarchy.
-        var node = pgBrowser.Nodes[d._type],
-          parentData = node.getTreeNodeHierarchy(i);
+      // Get the parent data from the tree node hierarchy.
+      var node = pgBrowser.Nodes[d._type],
+        parentData = node.getTreeNodeHierarchy(i);
 
-        // If server, database or schema is undefined then return from the function.
-        if (parentData.server === undefined || parentData.database === undefined) {
-          return;
-        }
-        // If schema, view, catalog object all are undefined then return from the function.
-        if (parentData.schema === undefined && parentData.view === undefined &&
-             parentData.catalog === undefined) {
-          return;
-        }
+      // If server, database or schema is undefined then return from the function.
+      if (parentData.server === undefined || parentData.database === undefined) {
+        return;
+      }
+      // If schema, view, catalog object all are undefined then return from the function.
+      if (parentData.schema === undefined && parentData.view === undefined &&
+        parentData.catalog === undefined) {
+        return;
+      }
 
-        var nsp_name = '';
+      var nsp_name = '';
 
-        if (parentData.schema != undefined) {
-            nsp_name = parentData.schema.label;
-        }
-        else if (parentData.view != undefined) {
-            nsp_name = parentData.view.label;
-        }
-        else if (parentData.catalog != undefined) {
-            nsp_name = parentData.catalog.label;
-        }
-        var url_params = {
-          'cmd_type': data.mnuid,
-          'obj_type': d._type,
-          'sid': parentData.server._id,
-          'did': parentData.database._id,
-          'obj_id': d._id
-        };
+      if (parentData.schema != undefined) {
+        nsp_name = parentData.schema.label;
+      } else if (parentData.view != undefined) {
+        nsp_name = parentData.view.label;
+      } else if (parentData.catalog != undefined) {
+        nsp_name = parentData.catalog.label;
+      }
+      var url_params = {
+        'cmd_type': data.mnuid,
+        'obj_type': d._type,
+        'sid': parentData.server._id,
+        'did': parentData.database._id,
+        'obj_id': d._id,
+      };
+
+      var baseUrl = url_for('datagrid.initialize_datagrid', url_params);
+      var grid_title = parentData.server.label + ' - ' + parentData.database.label + ' - ' +
+        nsp_name + '.' + d.label;
+
+      // Initialize the data grid.
+      self.initialize_data_grid(baseUrl, grid_title, '', parentData.server.server_type);
+    },
+
+    // This is a callback function to show filtered data when user click on menu item.
+    show_filtered_row: function(data, i) {
+      var self = this,
+        d = pgAdmin.Browser.tree.itemData(i);
+      if (d === undefined) {
+        Alertify.alert(
+          gettext('Data Grid Error'),
+          gettext('No object selected.')
+        );
+        return;
+      }
 
-        var baseUrl = url_for('datagrid.initialize_datagrid', url_params);
-        var grid_title = parentData.server.label + ' - ' + parentData.database.label + ' - '
-                        + nsp_name + '.' + d.label;
-
-        // Initialize the data grid.
-        self.initialize_data_grid(baseUrl, grid_title, '', parentData.server.server_type);
-      },
-
-      // This is a callback function to show filtered data when user click on menu item.
-      show_filtered_row: function(data, i) {
-        var self = this,
-            d = pgAdmin.Browser.tree.itemData(i);
-        if (d === undefined) {
-          alertify.alert(
-            gettext('Data Grid Error'),
-            gettext('No object selected.')
-          );
-          return;
-        }
+      // Get the parent data from the tree node hierarchy.
+      var node = pgBrowser.Nodes[d._type],
+        parentData = node.getTreeNodeHierarchy(i);
 
-        // Get the parent data from the tree node hierarchy.
-        var node = pgBrowser.Nodes[d._type],
-          parentData = node.getTreeNodeHierarchy(i);
+      // If server or database is undefined then return from the function.
+      if (parentData.server === undefined || parentData.database === undefined) {
+        return;
+      }
 
-        // If server or database is undefined then return from the function.
-        if (parentData.server === undefined || parentData.database === undefined) {
-          return;
-        }
+      // If schema, view, catalog object all are undefined then return from the function.
+      if (parentData.schema === undefined && parentData.view === undefined &&
+        parentData.catalog === undefined) {
+        return;
+      }
 
-        // If schema, view, catalog object all are undefined then return from the function.
-        if (parentData.schema === undefined && parentData.view === undefined &&
-             parentData.catalog === undefined) {
-          return;
-        }
+      var nsp_name = '';
 
-        var nsp_name = '';
+      if (parentData.schema != undefined) {
+        nsp_name = parentData.schema.label;
+      } else if (parentData.view != undefined) {
+        nsp_name = parentData.view.label;
+      } else if (parentData.catalog != undefined) {
+        nsp_name = parentData.catalog.label;
+      }
 
-        if (parentData.schema != undefined) {
-            nsp_name = parentData.schema.label;
-        }
-        else if (parentData.view != undefined) {
-            nsp_name = parentData.view.label;
-        }
-        else if (parentData.catalog != undefined) {
-            nsp_name = parentData.catalog.label;
-        }
+      var url_params = {
+        'cmd_type': data.mnuid,
+        'obj_type': d._type,
+        'sid': parentData.server._id,
+        'did': parentData.database._id,
+        'obj_id': d._id,
+
+      };
+
+      var baseUrl = url_for('datagrid.initialize_datagrid', url_params);
+
+      // Create url to validate the SQL filter
+      var validateUrl = url_for('datagrid.filter_validate', {
+        'sid': url_params['sid'],
+        'did': url_params['did'],
+        'obj_id': url_params['obj_id'],
+      });
+      var grid_title = parentData.server.label + '-' + parentData.database.label + '-' +
+        nsp_name + '.' + d.label;
+
+      // Create filter dialog using alertify
+      if (!Alertify.filterDialog) {
+        Alertify.dialog('filterDialog', function factory() {
+          return {
+            main: function(title, message, baseUrl, validateUrl) {
+              this.set('title', title);
+              this.message = message;
+              this.baseUrl = baseUrl;
+              this.validateUrl = validateUrl;
+            },
+
+            setup: function() {
+              return {
+                buttons: [{
+                  text: 'OK',
+                  className: 'btn btn-primary',
+                },
+                {
+                  text: 'Cancel',
+                  className: 'btn btn-danger',
+                },
+                ],
+                options: {
+                  modal: 0,
+                  resizable: true,
+                  maximizable: false,
+                  pinnable: false,
+                },
+              };
+            },
+            build: function() {
+              Alertify.pgDialogBuild.apply(this);
+            },
+            prepare: function() {
+              var self = this,
+                $content = $(this.message),
+                $sql_filter = $content.find('#sql_filter');
+
+              $(this.elements.body.childNodes[0]).addClass(
+                'dataview_filter_dialog'
+              );
+
+              this.setContent($content.get(0));
+
+              // Apply CodeMirror to filter text area.
+              this.filter_obj = CodeMirror.fromTextArea($sql_filter.get(0), {
+                lineNumbers: true,
+                mode: 'text/x-pgsql',
+                extraKeys: pgBrowser.editor_shortcut_keys,
+                indentWithTabs: pgAdmin.Browser.editor_options.indent_with_tabs,
+                indentUnit: pgAdmin.Browser.editor_options.tabSize,
+                tabSize: pgBrowser.editor_options.tabSize,
+                lineWrapping: pgAdmin.Browser.editor_options.wrapCode,
+                autoCloseBrackets: pgAdmin.Browser.editor_options.insert_pair_brackets,
+                matchBrackets: pgAdmin.Browser.editor_options.brace_matching,
+              });
 
-        var url_params = {
-          'cmd_type': data.mnuid,
-          'obj_type': d._type,
-          'sid': parentData.server._id,
-          'did': parentData.database._id,
-          'obj_id': d._id
+              setTimeout(function() {
+                // Set focus on editor
+                self.filter_obj.focus();
+              }, 500);
+            },
 
-        };
+            callback: function(closeEvent) {
 
-        var baseUrl = url_for('datagrid.initialize_datagrid', url_params);
-
-        // Create url to validate the SQL filter
-        var validateUrl = url_for('datagrid.filter_validate', {
-                        'sid': url_params['sid'],
-                        'did': url_params['did'],
-                        'obj_id': url_params['obj_id'],
-                      });
-        var grid_title = parentData.server.label + '-' + parentData.database.label + '-'
-                        + nsp_name + '.' + d.label;
-
-        // Create filter dialog using alertify
-        if (!alertify.filterDialog) {
-          alertify.dialog('filterDialog', function factory() {
-            return {
-              main: function(title, message, baseUrl, validateUrl) {
-                this.set('title', title);
-                this.message = message;
-                this.baseUrl = baseUrl;
-                this.validateUrl = validateUrl;
-              },
-
-              setup:function() {
-                return {
-                  buttons:[
-                    { text: "OK", className: "btn btn-primary" },
-                    { text: "Cancel", className: "btn btn-danger" }
-                  ],
-                  options: { modal: 0, resizable: true, maximizable: false, pinnable: false}
-                };
-              },
-              build: function() {
-                alertify.pgDialogBuild.apply(this)
-              },
-              prepare:function() {
-                var self = this,
-                  $content = $(this.message),
-                  $sql_filter = $content.find('#sql_filter');
-
-                $(this.elements.body.childNodes[0]).addClass(
-                  'dataview_filter_dialog'
-                );
-
-                this.setContent($content.get(0));
-
-                // Apply CodeMirror to filter text area.
-                this.filter_obj = CodeMirror.fromTextArea($sql_filter.get(0), {
-                  lineNumbers: true,
-                  mode: "text/x-pgsql",
-                  extraKeys: pgBrowser.editor_shortcut_keys,
-                  indentWithTabs: pgAdmin.Browser.editor_options.indent_with_tabs,
-                  indentUnit: pgAdmin.Browser.editor_options.tabSize,
-                  tabSize: pgBrowser.editor_options.tabSize,
-                  lineWrapping: pgAdmin.Browser.editor_options.wrapCode,
-                  autoCloseBrackets: pgAdmin.Browser.editor_options.insert_pair_brackets,
-                  matchBrackets: pgAdmin.Browser.editor_options.brace_matching
-                });
+              if (closeEvent.button.text == gettext('OK')) {
+                var sql = this.filter_obj.getValue();
+                var that = this;
 
-                setTimeout(function() {
-                  // Set focus on editor
-                  self.filter_obj.focus();
-                }, 500);
-              },
-
-              callback: function(closeEvent) {
-
-                if (closeEvent.button.text == gettext("OK")) {
-                  var sql = this.filter_obj.getValue();
-                  var that = this;
-
-                  // Make ajax call to include the filter by selection
-                  $.ajax({
-                    url: that.validateUrl,
-                    method: 'POST',
-                    async: false,
-                    contentType: "application/json",
-                    data: JSON.stringify(sql),
-                    success: function(res) {
-                      if (res.data.status) {
-                        // Initialize the data grid.
-                        self.initialize_data_grid(that.baseUrl, grid_title, sql, parentData.server.server_type);
-                      }
-                      else {
-                        alertify.alert(
-                          gettext('Validation Error'),
-                            res.data.result
-                        );
-                      }
-                    },
-                    error: function(e) {
-                      alertify.alert(
+                // Make ajax call to include the filter by selection
+                $.ajax({
+                  url: that.validateUrl,
+                  method: 'POST',
+                  async: false,
+                  contentType: 'application/json',
+                  data: JSON.stringify(sql),
+                  success: function(res) {
+                    if (res.data.status) {
+                      // Initialize the data grid.
+                      self.initialize_data_grid(that.baseUrl, grid_title, sql, parentData.server.server_type);
+                    } else {
+                      Alertify.alert(
                         gettext('Validation Error'),
-                        e
+                        res.data.result
                       );
                     }
-                  });
-                }
+                  },
+                  error: function(e) {
+                    Alertify.alert(
+                      gettext('Validation Error'),
+                      e
+                    );
+                  },
+                });
               }
-            };
-          });
-        }
-
-        var content = '';
-        $.get(url_for('datagrid.filter'),
-          function(data) {
-            alertify.filterDialog('Data Filter', data, baseUrl, validateUrl)
-                    .resizeTo(300, 200);
-          }
-        );
-      },
-
-      get_panel_title: function() {
-        // Get the parent data from the tree node hierarchy.
-        var tree = pgAdmin.Browser.tree,
-            selected_item = tree.selected(),
-            item_data = tree.itemData(selected_item);
-        var self = this;
-
-        var node = pgBrowser.Nodes[item_data._type],
-          parentData = node.getTreeNodeHierarchy(selected_item);
+            },
+          };
+        });
+      }
 
-        // If server, database is undefined then return from the function.
-        if (parentData.server === undefined) {
-          return;
+      $.get(url_for('datagrid.filter'),
+        function(data) {
+          Alertify.filterDialog('Data Filter', data, baseUrl, validateUrl)
+            .resizeTo(300, 200);
         }
-        // If Database is not available then use default db
-        var db_label = parentData.database ? parentData.database.label
-                                           : parentData.server.db;
-
-        var grid_title = db_label + ' on ' + parentData.server.user.name + '@' +
-                parentData.server.label;
-        return grid_title;
-      },
-
-      initialize_data_grid: function(baseUrl, grid_title, sql_filter, server_type) {
-        var self = this;
-          self.grid_title = grid_title;
-
-        /* Ajax call to initialize the edit grid, which creates
-         * an asynchronous connection and create appropriate query
-         * for the selected node.
-         */
-        $.ajax({
-          url: baseUrl,
-          method: 'POST',
-          dataType: 'json',
-          contentType: "application/json",
-          data: JSON.stringify(sql_filter),
-          success: function(res) {
-
-            /* On successfully initialization find the dashboard panel,
-             * create new panel and add it to the dashboard panel.
-             */
-            var url_params = {
-              'trans_id': res.data.gridTransId,
-              'is_query_tool': 'false',
-              'editor_title': encodeURIComponent(self.grid_title)
-            };
-
-            var baseUrl = url_for('datagrid.panel', url_params) +
-              "?query_url=&server_type=" + encodeURIComponent(server_type);
-            var grid_title = gettext('Edit Data - ') + self.grid_title;
-            if (res.data.newBrowserTab) {
-              var newWin = window.open(baseUrl, '_blank');
-
-              // add a load listener to the window so that the title gets changed on page load
-              newWin.addEventListener("load", function() {
-                newWin.document.title = grid_title;
-              });
-            } else {
-              var propertiesPanel = pgBrowser.docker.findPanels('properties');
-              var dataGridPanel = pgBrowser.docker.addPanel('frm_datagrid', wcDocker.DOCK.STACKED, propertiesPanel[0]);
-
-              // Set panel title and icon
-              dataGridPanel.title('<span title="'+grid_title+'">'+grid_title+'</span>');
-              dataGridPanel.icon('fa fa-bolt');
-              dataGridPanel.focus();
-
-              // Listen on the panel closed event.
-              dataGridPanel.on(wcDocker.EVENT.CLOSED, function() {
-                $.ajax({
-                  url: url_for('datagrid.close', {'trans_id': res.data.gridTransId}),
-                  method: 'GET'
-                });
+      );
+    },
+
+    get_panel_title: function() {
+      // Get the parent data from the tree node hierarchy.
+      var tree = pgAdmin.Browser.tree,
+        selected_item = tree.selected(),
+        item_data = tree.itemData(selected_item),
+        node = pgBrowser.Nodes[item_data._type],
+        parentData = node.getTreeNodeHierarchy(selected_item);
+
+      // If server, database is undefined then return from the function.
+      if (parentData.server === undefined) {
+        return;
+      }
+      // If Database is not available then use default db
+      var db_label = parentData.database ? parentData.database.label :
+        parentData.server.db;
+
+      var grid_title = db_label + ' on ' + parentData.server.user.name + '@' +
+        parentData.server.label;
+      return grid_title;
+    },
+
+    initialize_data_grid: function(baseUrl, grid_title, sql_filter, server_type) {
+      var self = this;
+      self.grid_title = grid_title;
+
+      /* Ajax call to initialize the edit grid, which creates
+       * an asynchronous connection and create appropriate query
+       * for the selected node.
+       */
+      $.ajax({
+        url: baseUrl,
+        method: 'POST',
+        dataType: 'json',
+        contentType: 'application/json',
+        data: JSON.stringify(sql_filter),
+        success: function(res) {
+
+          /* On successfully initialization find the dashboard panel,
+           * create new panel and add it to the dashboard panel.
+           */
+          var url_params = {
+            'trans_id': res.data.gridTransId,
+            'is_query_tool': 'false',
+            'editor_title': encodeURIComponent(self.grid_title),
+          };
+
+          var baseUrl = url_for('datagrid.panel', url_params) +
+            '?query_url=&server_type=' + encodeURIComponent(server_type);
+          var grid_title = gettext('Edit Data - ') + self.grid_title;
+          if (res.data.newBrowserTab) {
+            var newWin = window.open(baseUrl, '_blank');
+
+            // add a load listener to the window so that the title gets changed on page load
+            newWin.addEventListener('load', function() {
+              newWin.document.title = grid_title;
+            });
+          } else {
+            var propertiesPanel = pgBrowser.docker.findPanels('properties');
+            var dataGridPanel = pgBrowser.docker.addPanel('frm_datagrid', wcDocker.DOCK.STACKED, propertiesPanel[0]);
+
+            // Set panel title and icon
+            dataGridPanel.title('<span title="' + grid_title + '">' + grid_title + '</span>');
+            dataGridPanel.icon('fa fa-bolt');
+            dataGridPanel.focus();
+
+            // Listen on the panel closed event.
+            dataGridPanel.on(wcDocker.EVENT.CLOSED, function() {
+              $.ajax({
+                url: url_for('datagrid.close', {
+                  'trans_id': res.data.gridTransId,
+                }),
+                method: 'GET',
               });
-
-              var openDataGridURL = function(j) {
-                // add spinner element
-                $(j).data('embeddedFrame').$container.append(self.spinner_el);
-                setTimeout(function() {
-                  var frameInitialized = $(j).data('frameInitialized');
-                  if (frameInitialized) {
-                    var frame = $(j).data('embeddedFrame');
-                    if (frame) {
-                      frame.openURL(baseUrl);
-                      frame.$container.find('.wcLoadingContainer').hide(1);
-                    }
-                  } else {
-                    openDataGridURL(j);
+            });
+
+            var openDataGridURL = function(j) {
+              // add spinner element
+              $(j).data('embeddedFrame').$container.append(self.spinner_el);
+              setTimeout(function() {
+                var frameInitialized = $(j).data('frameInitialized');
+                if (frameInitialized) {
+                  var frame = $(j).data('embeddedFrame');
+                  if (frame) {
+                    frame.openURL(baseUrl);
+                    frame.$container.find('.wcLoadingContainer').hide(1);
                   }
-                }, 100);
-              };
+                } else {
+                  openDataGridURL(j);
+                }
+              }, 100);
+            };
 
-              openDataGridURL(dataGridPanel);
-            }
-          },
-          error: function(e) {
-            alertify.alert(
-              gettext('Error'),
-              gettext('Query Tool Initialization Error')
-            );
+            openDataGridURL(dataGridPanel);
           }
-        });
-      },
-
-      // This is a callback function to show query tool when user click on menu item.
-      show_query_tool: function(url, i, panel_title) {
-        var self = this,
-          sURL = url || '',
-          panel_title = panel_title || '',
-          d = pgAdmin.Browser.tree.itemData(i);
-        if (d === undefined) {
-          alertify.alert(
-            gettext('Query Tool Error'),
-            gettext('No object selected.')
+        },
+        error: function() {
+          Alertify.alert(
+            gettext('Error'),
+            gettext('Query Tool Initialization Error')
           );
-          return;
-        }
+        },
+      });
+    },
 
-        // Get the parent data from the tree node hierarchy.
-        var node = pgBrowser.Nodes[d._type],
-          parentData = node.getTreeNodeHierarchy(i);
+    // This is a callback function to show query tool when user click on menu item.
+    show_query_tool: function(url, i, panel_title) {
+      var self = this,
+        sURL = url || '',
+        d = pgAdmin.Browser.tree.itemData(i);
 
-        // If server, database is undefined then return from the function.
-        if (parentData.server === undefined) {
-          return;
-        }
+      panel_title = panel_title || '';
 
-        var url_params = {
-          'sid': parentData.server._id
-        };
-        var url_endpoint = 'datagrid.initialize_query_tool'
-        // If database not present then use Maintenance database
-        // We will handle this at server side
-        if (parentData.database) {
-          url_params['did'] = parentData.database._id;
-          url_endpoint = 'datagrid.initialize_query_tool_with_did';
-        }
-        var baseUrl = url_for(url_endpoint, url_params);
-
-        $.ajax({
-          url: baseUrl,
-          method: 'POST',
-          dataType: 'json',
-          contentType: "application/json",
-          success: function(res) {
-            var grid_title = self.get_panel_title();
-            // Open the panel if frame is initialized
-            var url_params = {
-              'trans_id': res.data.gridTransId,
-              'is_query_tool': 'true',
-              'editor_title': encodeURIComponent(grid_title)
-            }
+      if (d === undefined) {
+        Alertify.alert(
+          gettext('Query Tool Error'),
+          gettext('No object selected.')
+        );
+        return;
+      }
 
-            var baseUrl = url_for('datagrid.panel', url_params) +
-                '?' + "query_url=" + encodeURI(sURL) + "&server_type=" + encodeURIComponent(parentData.server.server_type);
+      // Get the parent data from the tree node hierarchy.
+      var node = pgBrowser.Nodes[d._type],
+        parentData = node.getTreeNodeHierarchy(i);
 
-            // Create title for CREATE/DELETE scripts
-            if (panel_title) {
-              panel_title =
-                sqlEditorUtils.capitalizeFirstLetter(panel_title) + ' script';
-            }
-            else {
-              panel_title = gettext('Query - ') + grid_title;
-            }
+      // If server, database is undefined then return from the function.
+      if (parentData.server === undefined) {
+        return;
+      }
 
-            if (res.data.newBrowserTab) {
-              var newWin = window.open(baseUrl, '_blank');
+      var url_params = {
+        'sid': parentData.server._id,
+      };
+      var url_endpoint = 'datagrid.initialize_query_tool';
+      // If database not present then use Maintenance database
+      // We will handle this at server side
+      if (parentData.database) {
+        url_params['did'] = parentData.database._id;
+        url_endpoint = 'datagrid.initialize_query_tool_with_did';
+      }
+      var baseUrl = url_for(url_endpoint, url_params);
+
+      $.ajax({
+        url: baseUrl,
+        method: 'POST',
+        dataType: 'json',
+        contentType: 'application/json',
+        success: function(res) {
+          var grid_title = self.get_panel_title();
+          // Open the panel if frame is initialized
+          var url_params = {
+            'trans_id': res.data.gridTransId,
+            'is_query_tool': 'true',
+            'editor_title': encodeURIComponent(grid_title),
+          };
+
+          var baseUrl = url_for('datagrid.panel', url_params) +
+            '?' + 'query_url=' + encodeURI(sURL) + '&server_type=' + encodeURIComponent(parentData.server.server_type);
+
+          // Create title for CREATE/DELETE scripts
+          if (panel_title) {
+            panel_title =
+              sqlEditorUtils.capitalizeFirstLetter(panel_title) + ' script';
+          } else {
+            panel_title = gettext('Query - ') + grid_title;
+          }
 
-              // add a load listener to the window so that the title gets changed on page load
-              newWin.addEventListener("load", function() {
-                newWin.document.title = panel_title;
-              });
-            } else {
-              /* On successfully initialization find the dashboard panel,
-               * create new panel and add it to the dashboard panel.
-               */
-              var propertiesPanel = pgBrowser.docker.findPanels('properties');
-              var queryToolPanel = pgBrowser.docker.addPanel('frm_datagrid', wcDocker.DOCK.STACKED, propertiesPanel[0]);
-
-              // Set panel title and icon
-              queryToolPanel.title('<span title="'+panel_title+'">'+panel_title+'</span>');
-              queryToolPanel.icon('fa fa-bolt');
-              queryToolPanel.focus();
-
-              // Listen on the panel closed event.
-              queryToolPanel.on(wcDocker.EVENT.CLOSED, function() {
-                $.ajax({
-                  url: url_for('datagrid.close', {'trans_id': res.data.gridTransId}),
-                  method: 'GET'
-                });
-              });
+          if (res.data.newBrowserTab) {
+            var newWin = window.open(baseUrl, '_blank');
 
-              var openQueryToolURL = function(j) {
-                // add spinner element
-                $(j).data('embeddedFrame').$container.append(pgAdmin.DataGrid.spinner_el);
-                setTimeout(function() {
-                  var frameInitialized = $(j).data('frameInitialized');
-                  if (frameInitialized) {
-                    var frame = $(j).data('embeddedFrame');
-                    if (frame) {
-                      frame.openURL(baseUrl);
-                      frame.$container.find('.wcLoadingContainer').delay(1000).hide(1);
-                    }
-                  } else {
-                    openQueryToolURL(j);
+            // add a load listener to the window so that the title gets changed on page load
+            newWin.addEventListener('load', function() {
+              newWin.document.title = panel_title;
+            });
+          } else {
+            /* On successfully initialization find the dashboard panel,
+             * create new panel and add it to the dashboard panel.
+             */
+            var propertiesPanel = pgBrowser.docker.findPanels('properties');
+            var queryToolPanel = pgBrowser.docker.addPanel('frm_datagrid', wcDocker.DOCK.STACKED, propertiesPanel[0]);
+
+            // Set panel title and icon
+            queryToolPanel.title('<span title="' + panel_title + '">' + panel_title + '</span>');
+            queryToolPanel.icon('fa fa-bolt');
+            queryToolPanel.focus();
+
+            // Listen on the panel closed event.
+            queryToolPanel.on(wcDocker.EVENT.CLOSED, function() {
+              $.ajax({
+                url: url_for('datagrid.close', {
+                  'trans_id': res.data.gridTransId,
+                }),
+                method: 'GET',
+              });
+            });
+
+            var openQueryToolURL = function(j) {
+              // add spinner element
+              $(j).data('embeddedFrame').$container.append(pgAdmin.DataGrid.spinner_el);
+              setTimeout(function() {
+                var frameInitialized = $(j).data('frameInitialized');
+                if (frameInitialized) {
+                  var frame = $(j).data('embeddedFrame');
+                  if (frame) {
+                    frame.openURL(baseUrl);
+                    frame.$container.find('.wcLoadingContainer').delay(1000).hide(1);
                   }
-                }, 100);
-              };
+                } else {
+                  openQueryToolURL(j);
+                }
+              }, 100);
+            };
 
-              openQueryToolURL(queryToolPanel);
-            }
-          },
-          error: function(e) {
-            alertify.alert(
-              gettext("Query Tool Initialize Error")
-            );
+            openQueryToolURL(queryToolPanel);
           }
-        });
-      }
-    };
+        },
+        error: function() {
+          Alertify.alert(
+            gettext('Query Tool Initialize Error')
+          );
+        },
+      });
+    },
+  };
 
-    return pgAdmin.DataGrid;
-  });
+  return pgAdmin.DataGrid;
+});
\ No newline at end of file
diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
index dbc416ec..40c975cb 100644
--- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
@@ -1,49 +1,49 @@
 define('tools.querytool', [
-    'babel-polyfill', 'sources/gettext','sources/url_for', 'jquery',
-    'underscore', 'underscore.string', 'pgadmin.alertifyjs',
-    'sources/pgadmin', 'backbone', 'sources/../bundle/codemirror',
-    'pgadmin.misc.explain',
-    'sources/selection/grid_selector',
-    'sources/selection/active_cell_capture',
-    'sources/selection/clipboard',
-    'sources/selection/copy_data',
-    'sources/selection/range_selection_helper',
-    'sources/slickgrid/event_handlers/handle_query_output_keyboard_event',
-    'sources/selection/xcell_selection_model',
-    'sources/selection/set_staged_rows',
-    'sources/sqleditor_utils',
-    'sources/history/index.js',
-    'sources/../jsx/history/query_history',
-    'react', 'react-dom',
-    'sources/sqleditor/keyboard_shortcuts',
-    'sources/sqleditor/query_tool_actions',
+  'babel-polyfill', 'sources/gettext', 'sources/url_for', 'jquery',
+  'underscore', 'underscore.string', 'pgadmin.alertifyjs',
+  'sources/pgadmin', 'backbone', 'sources/../bundle/codemirror',
+  'pgadmin.misc.explain',
+  'sources/selection/grid_selector',
+  'sources/selection/active_cell_capture',
+  'sources/selection/clipboard',
+  'sources/selection/copy_data',
+  'sources/selection/range_selection_helper',
+  'sources/slickgrid/event_handlers/handle_query_output_keyboard_event',
+  'sources/selection/xcell_selection_model',
+  'sources/selection/set_staged_rows',
+  'sources/sqleditor_utils',
+  'sources/history/index.js',
+  'sources/../jsx/history/query_history',
+  'react', 'react-dom',
+  'sources/sqleditor/keyboard_shortcuts',
+  'sources/sqleditor/query_tool_actions',
   'sources/../bundle/slickgrid',
-    'pgadmin.file_manager',
-    'backgrid.sizeable.columns',
-    'slick.pgadmin.formatters',
-    'slick.pgadmin.editors',
-    'pgadmin.browser'
+  'pgadmin.file_manager',
+  'backgrid.sizeable.columns',
+  'slick.pgadmin.formatters',
+  'slick.pgadmin.editors',
+  'pgadmin.browser',
 ], function(
-  babelPollyfill,gettext, url_for, $, _, S, alertify, pgAdmin, Backbone, codemirror,
+  babelPollyfill, gettext, url_for, $, _, S, alertify, pgAdmin, Backbone, codemirror,
   pgExplain, GridSelector, ActiveCellCapture, clipboard, copyData, RangeSelectionHelper, handleQueryOutputKeyboardEvent,
-  XCellSelectionModel, setStagedRows,  SqlEditorUtils, HistoryBundle, queryHistory, React, ReactDOM,
-  keyboardShortcuts
-, queryToolActions) {
-    /* Return back, this has been called more than once */
-    if (pgAdmin.SqlEditor)
-      return pgAdmin.SqlEditor;
-
-    // Some scripts do export their object in the window only.
-    // Generally the one, which do no have AMD support.
-    var wcDocker = window.wcDocker,
-        pgBrowser = pgAdmin.Browser,
-        CodeMirror = codemirror.default,Slick = window.Slick;
+  XCellSelectionModel, setStagedRows, SqlEditorUtils, HistoryBundle, queryHistory, React, ReactDOM,
+  keyboardShortcuts, queryToolActions) {
+  /* Return back, this has been called more than once */
+  if (pgAdmin.SqlEditor)
+    return pgAdmin.SqlEditor;
+
+  // Some scripts do export their object in the window only.
+  // Generally the one, which do no have AMD support.
+  var wcDocker = window.wcDocker,
+    pgBrowser = pgAdmin.Browser,
+    CodeMirror = codemirror.default,
+    Slick = window.Slick;
 
   var is_query_running = false;
 
   // Defining Backbone view for the sql grid.
   var SQLEditorView = Backbone.View.extend({
-    initialize: function (opts) {
+    initialize: function(opts) {
       this.$el = opts.el;
       this.handler = opts.handler;
       this.handler['col_size'] = {};
@@ -51,80 +51,80 @@ define('tools.querytool', [
 
     // Bind all the events
     events: {
-      "click .btn-load-file": "on_file_load",
-      "click #btn-save": "on_save",
-      "click #btn-file-menu-save": "on_save",
-      "click #btn-file-menu-save-as": "on_save_as",
-      "click #btn-find": "on_find",
-      "click #btn-find-menu-find": "on_find",
-      "click #btn-find-menu-find-next": "on_find_next",
-      "click #btn-find-menu-find-previous": "on_find_previous",
-      "click #btn-find-menu-replace": "on_replace",
-      "click #btn-find-menu-replace-all": "on_replace_all",
-      "click #btn-find-menu-find-persistent": "on_find_persistent",
-      "click #btn-find-menu-jump": "on_jump",
-      "click #btn-delete-row": "on_delete",
-      "click #btn-filter": "on_show_filter",
-      "click #btn-filter-menu": "on_show_filter",
-      "click #btn-include-filter": "on_include_filter",
-      "click #btn-exclude-filter": "on_exclude_filter",
-      "click #btn-remove-filter": "on_remove_filter",
-      "click #btn-apply": "on_apply",
-      "click #btn-cancel": "on_cancel",
-      "click #btn-copy-row": "on_copy_row",
-      "click #btn-paste-row": "on_paste_row",
-      "click #btn-flash": "on_flash",
-      "click #btn-flash-menu": "on_flash",
-      "click #btn-cancel-query": "on_cancel_query",
-      "click #btn-download": "on_download",
-      "click #btn-edit": "on_clear",
-      "click #btn-clear": "on_clear",
-      "click #btn-auto-commit": "on_auto_commit",
-      "click #btn-auto-rollback": "on_auto_rollback",
-      "click #btn-clear-history": "on_clear_history",
-      "click .noclose": 'do_not_close_menu',
-      "click #btn-explain": "on_explain",
-      "click #btn-explain-analyze": "on_explain_analyze",
-      "click #btn-explain-verbose": "on_explain_verbose",
-      "click #btn-explain-costs": "on_explain_costs",
-      "click #btn-explain-buffers": "on_explain_buffers",
-      "click #btn-explain-timing": "on_explain_timing",
-      "change .limit": "on_limit_change",
-      "keydown": "keyAction",
+      'click .btn-load-file': 'on_file_load',
+      'click #btn-save': 'on_save',
+      'click #btn-file-menu-save': 'on_save',
+      'click #btn-file-menu-save-as': 'on_save_as',
+      'click #btn-find': 'on_find',
+      'click #btn-find-menu-find': 'on_find',
+      'click #btn-find-menu-find-next': 'on_find_next',
+      'click #btn-find-menu-find-previous': 'on_find_previous',
+      'click #btn-find-menu-replace': 'on_replace',
+      'click #btn-find-menu-replace-all': 'on_replace_all',
+      'click #btn-find-menu-find-persistent': 'on_find_persistent',
+      'click #btn-find-menu-jump': 'on_jump',
+      'click #btn-delete-row': 'on_delete',
+      'click #btn-filter': 'on_show_filter',
+      'click #btn-filter-menu': 'on_show_filter',
+      'click #btn-include-filter': 'on_include_filter',
+      'click #btn-exclude-filter': 'on_exclude_filter',
+      'click #btn-remove-filter': 'on_remove_filter',
+      'click #btn-apply': 'on_apply',
+      'click #btn-cancel': 'on_cancel',
+      'click #btn-copy-row': 'on_copy_row',
+      'click #btn-paste-row': 'on_paste_row',
+      'click #btn-flash': 'on_flash',
+      'click #btn-flash-menu': 'on_flash',
+      'click #btn-cancel-query': 'on_cancel_query',
+      'click #btn-download': 'on_download',
+      'click #btn-edit': 'on_clear',
+      'click #btn-clear': 'on_clear',
+      'click #btn-auto-commit': 'on_auto_commit',
+      'click #btn-auto-rollback': 'on_auto_rollback',
+      'click #btn-clear-history': 'on_clear_history',
+      'click .noclose': 'do_not_close_menu',
+      'click #btn-explain': 'on_explain',
+      'click #btn-explain-analyze': 'on_explain_analyze',
+      'click #btn-explain-verbose': 'on_explain_verbose',
+      'click #btn-explain-costs': 'on_explain_costs',
+      'click #btn-explain-buffers': 'on_explain_buffers',
+      'click #btn-explain-timing': 'on_explain_timing',
+      'change .limit': 'on_limit_change',
+      'keydown': 'keyAction',
       // Comment options
-      "click #btn-comment-code": "on_toggle_comment_block_code",
-      "click #btn-toggle-comment-block": "on_toggle_comment_block_code",
-      "click #btn-comment-line": "on_comment_line_code",
-      "click #btn-uncomment-line": "on_uncomment_line_code",
+      'click #btn-comment-code': 'on_toggle_comment_block_code',
+      'click #btn-toggle-comment-block': 'on_toggle_comment_block_code',
+      'click #btn-comment-line': 'on_comment_line_code',
+      'click #btn-uncomment-line': 'on_uncomment_line_code',
       // Indentation options
-      "click #btn-indent-code": "on_indent_code",
-      "click #btn-unindent-code": "on_unindent_code"
+      'click #btn-indent-code': 'on_indent_code',
+      'click #btn-unindent-code': 'on_unindent_code',
     },
 
     // This function is used to render the template.
-    render: function () {
+    render: function() {
       var self = this,
         filter = self.$el.find('#sql_filter');
 
       $('.editor-title').text(_.unescape(self.editor_title));
       self.filter_obj = CodeMirror.fromTextArea(filter.get(0), {
         lineNumbers: true,
-        mode: self.handler.server_type === "gpdb" ? "text/x-gpsql" : "text/x-pgsql",
+        mode: self.handler.server_type === 'gpdb' ? 'text/x-gpsql' : 'text/x-pgsql',
         foldOptions: {
-          widget: "\u2026"
+          widget: '\u2026',
         },
         foldGutter: {
           rangeFinder: CodeMirror.fold.combine(CodeMirror.pgadminBeginRangeFinder, CodeMirror.pgadminIfRangeFinder,
-            CodeMirror.pgadminLoopRangeFinder, CodeMirror.pgadminCaseRangeFinder)
+            CodeMirror.pgadminLoopRangeFinder, CodeMirror.pgadminCaseRangeFinder),
         },
-        gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
+        gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter'],
         extraKeys: pgBrowser.editor_shortcut_keys,
         indentWithTabs: pgAdmin.Browser.editor_options.indent_with_tabs,
         indentUnit: pgAdmin.Browser.editor_options.tabSize,
         tabSize: pgAdmin.Browser.editor_options.tabSize,
         lineWrapping: pgAdmin.Browser.editor_options.wrapCode,
         autoCloseBrackets: pgAdmin.Browser.editor_options.insert_pair_brackets,
-        matchBrackets: pgAdmin.Browser.editor_options.brace_matching
+        matchBrackets: pgAdmin.Browser.editor_options.brace_matching,
       });
 
       // Create main wcDocker instance
@@ -132,8 +132,10 @@ define('tools.querytool', [
         '#editor-panel', {
           allowContextMenu: false,
           allowCollapse: false,
-          themePath: url_for('static', {'filename': 'css'}),
-          theme: 'webcabin.overrides.css'
+          themePath: url_for('static', {
+            'filename': 'css',
+          }),
+          theme: 'webcabin.overrides.css',
         });
 
       var sql_panel = new pgAdmin.Browser.Panel({
@@ -142,7 +144,7 @@ define('tools.querytool', [
         width: '100%',
         height: '20%',
         isCloseable: false,
-        isPrivate: true
+        isPrivate: true,
       });
 
       sql_panel.load(main_docker);
@@ -155,15 +157,15 @@ define('tools.querytool', [
       self.query_tool_obj = CodeMirror.fromTextArea(text_container.get(0), {
         lineNumbers: true,
         styleSelectedText: true,
-        mode: self.handler.server_type === "gpdb" ? "text/x-gpsql" : "text/x-pgsql",
+        mode: self.handler.server_type === 'gpdb' ? 'text/x-gpsql' : 'text/x-pgsql',
         foldOptions: {
-          widget: "\u2026"
+          widget: '\u2026',
         },
         foldGutter: {
           rangeFinder: CodeMirror.fold.combine(CodeMirror.pgadminBeginRangeFinder, CodeMirror.pgadminIfRangeFinder,
-            CodeMirror.pgadminLoopRangeFinder, CodeMirror.pgadminCaseRangeFinder)
+            CodeMirror.pgadminLoopRangeFinder, CodeMirror.pgadminCaseRangeFinder),
         },
-        gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
+        gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter'],
         extraKeys: pgBrowser.editor_shortcut_keys,
         indentWithTabs: pgAdmin.Browser.editor_options.indent_with_tabs,
         indentUnit: pgAdmin.Browser.editor_options.tabSize,
@@ -171,13 +173,13 @@ define('tools.querytool', [
         lineWrapping: pgAdmin.Browser.editor_options.wrapCode,
         scrollbarStyle: 'simple',
         autoCloseBrackets: pgAdmin.Browser.editor_options.insert_pair_brackets,
-        matchBrackets: pgAdmin.Browser.editor_options.brace_matching
+        matchBrackets: pgAdmin.Browser.editor_options.brace_matching,
       });
 
       // Refresh Code mirror on SQL panel resize to
       // display its value properly
-      sql_panel_obj.on(wcDocker.EVENT.RESIZE_ENDED, function () {
-        setTimeout(function () {
+      sql_panel_obj.on(wcDocker.EVENT.RESIZE_ENDED, function() {
+        setTimeout(function() {
           if (self && self.query_tool_obj) {
             self.query_tool_obj.refresh();
           }
@@ -187,43 +189,43 @@ define('tools.querytool', [
       // Create panels for 'Data Output', 'Explain', 'Messages' and 'History'
       var data_output = new pgAdmin.Browser.Panel({
         name: 'data_output',
-        title: gettext("Data Output"),
+        title: gettext('Data Output'),
         width: '100%',
         height: '100%',
         isCloseable: false,
         isPrivate: true,
-        content: '<div id ="datagrid" class="sql-editor-grid-container text-12"></div>'
-      })
+        content: '<div id ="datagrid" class="sql-editor-grid-container text-12"></div>',
+      });
 
       var explain = new pgAdmin.Browser.Panel({
         name: 'explain',
-        title: gettext("Explain"),
+        title: gettext('Explain'),
         width: '100%',
         height: '100%',
         isCloseable: false,
         isPrivate: true,
-        content: '<div class="sql-editor-explain"></div>'
-      })
+        content: '<div class="sql-editor-explain"></div>',
+      });
 
       var messages = new pgAdmin.Browser.Panel({
         name: 'messages',
-        title: gettext("Messages"),
+        title: gettext('Messages'),
         width: '100%',
         height: '100%',
         isCloseable: false,
         isPrivate: true,
-        content: '<div class="sql-editor-message"></div>'
-      })
+        content: '<div class="sql-editor-message"></div>',
+      });
 
       var history = new pgAdmin.Browser.Panel({
         name: 'history',
-        title: gettext("Query History"),
+        title: gettext('Query History'),
         width: '100%',
         height: '100%',
         isCloseable: false,
         isPrivate: true,
-        content: '<div id ="history_grid" class="sql-editor-history-container"></div>'
-      })
+        content: '<div id ="history_grid" class="sql-editor-history-container"></div>',
+      });
 
       // Load all the created panels
       data_output.load(main_docker);
@@ -241,21 +243,22 @@ define('tools.querytool', [
 
       if (!self.handler.is_new_browser_tab) {
         // Listen on the panel closed event and notify user to save modifications.
-        _.each(window.top.pgAdmin.Browser.docker.findPanels('frm_datagrid'), function (p) {
+        _.each(window.top.pgAdmin.Browser.docker.findPanels('frm_datagrid'), function(p) {
           if (p.isVisible()) {
-            if(self.handler.prompt_save_changes) {
-              p.on(wcDocker.EVENT.CLOSING, function () {
+            if (self.handler.prompt_save_changes) {
+              p.on(wcDocker.EVENT.CLOSING, function() {
                 // Only if we can edit data then perform this check
-                var notify = false, msg;
+                var notify = false,
+                  msg;
                 if (self.handler.can_edit) {
                   var data_store = self.handler.data_store;
                   if (data_store && (_.size(data_store.added) ||
-                    _.size(data_store.updated))) {
-                    msg = gettext("The data has changed. Do you want to save changes?");
+                      _.size(data_store.updated))) {
+                    msg = gettext('The data has changed. Do you want to save changes?');
                     notify = true;
                   }
                 } else if (self.handler.is_query_tool && self.handler.is_query_changed) {
-                  msg = gettext("The text has changed. Do you want to save changes?");
+                  msg = gettext('The text has changed. Do you want to save changes?');
                   notify = true;
                 }
                 if (notify) {
@@ -266,9 +269,9 @@ define('tools.querytool', [
             }
 
             // Set focus on query tool of active panel
-            p.on(wcDocker.EVENT.GAIN_FOCUS, function () {
+            p.on(wcDocker.EVENT.GAIN_FOCUS, function() {
               if (!$(p.$container).hasClass('wcPanelTabContentHidden')) {
-                setTimeout(function () {
+                setTimeout(function() {
                   self.handler.gridView.query_tool_obj.focus();
                 }, 200);
               }
@@ -278,14 +281,14 @@ define('tools.querytool', [
       }
 
       // set focus on query tool once loaded
-      setTimeout(function () {
+      setTimeout(function() {
         self.query_tool_obj.focus();
       }, 500);
 
       /* We have override/register the hint function of CodeMirror
        * to provide our own hint logic.
        */
-      CodeMirror.registerHelper("hint", "sql", function (editor, options) {
+      CodeMirror.registerHelper('hint', 'sql', function(editor) {
         var data = [],
           doc = editor.getDoc(),
           cur = doc.getCursor(),
@@ -295,7 +298,9 @@ define('tools.querytool', [
           ctx = {
             editor: editor,
             // URL for auto-complete
-            url: url_for('sqleditor.autocomplete', {'trans_id': self.transId}),
+            url: url_for('sqleditor.autocomplete', {
+              'trans_id': self.transId,
+            }),
             data: data,
             // Get the line number in the cursor position
             current_line: cur.line,
@@ -303,62 +308,67 @@ define('tools.querytool', [
              * Render function for hint to add our own class
              * and icon as per the object type.
              */
-            hint_render: function (elt, data, cur) {
+            hint_render: function(elt, data, cur) {
               var el = document.createElement('span');
 
               switch (cur.type) {
-                case 'database':
-                  el.className = 'sqleditor-hint pg-icon-' + cur.type;
-                  break;
-                case 'datatype':
-                  el.className = 'sqleditor-hint icon-type';
-                  break;
-                case 'keyword':
-                  el.className = 'fa fa-key';
-                  break;
-                case 'table alias':
-                  el.className = 'fa fa-at';
-                  break;
-                default:
-                  el.className = 'sqleditor-hint icon-' + cur.type;
+              case 'database':
+                el.className = 'sqleditor-hint pg-icon-' + cur.type;
+                break;
+              case 'datatype':
+                el.className = 'sqleditor-hint icon-type';
+                break;
+              case 'keyword':
+                el.className = 'fa fa-key';
+                break;
+              case 'table alias':
+                el.className = 'fa fa-at';
+                break;
+              default:
+                el.className = 'sqleditor-hint icon-' + cur.type;
               }
 
               el.appendChild(document.createTextNode(cur.text));
               elt.appendChild(el);
-            }
+            },
           };
 
         data.push(doc.getValue());
         // Get the text from start to the current cursor position.
         data.push(
-          doc.getRange(
-            {line: 0, ch: 0},
-            {line: ctx.current_line, ch: current_cur}
-          )
+          doc.getRange({
+            line: 0,
+            ch: 0,
+          }, {
+            line: ctx.current_line,
+            ch: current_cur,
+          })
         );
 
         return {
-          then: function (cb) {
+          then: function(cb) {
             var self = this;
             // Make ajax call to find the autocomplete data
             $.ajax({
               url: self.url,
               method: 'POST',
-              contentType: "application/json",
+              contentType: 'application/json',
               data: JSON.stringify(self.data),
-              success: function (res) {
+              success: function(res) {
                 var result = [];
 
-                _.each(res.data.result, function (obj, key) {
+                _.each(res.data.result, function(obj, key) {
                   result.push({
-                    text: key, type: obj.object_type,
-                    render: self.hint_render
+                    text: key,
+                    type: obj.object_type,
+                    render: self.hint_render,
                   });
                 });
 
                 // Sort function to sort the suggestion's alphabetically.
-                result.sort(function (a, b) {
-                  var textA = a.text.toLowerCase(), textB = b.text.toLowerCase();
+                result.sort(function(a, b) {
+                  var textA = a.text.toLowerCase(),
+                    textB = b.text.toLowerCase();
                   if (textA < textB) //sort string ascending
                     return -1;
                   if (textA > textB)
@@ -370,7 +380,8 @@ define('tools.querytool', [
                  * Below logic find the start and end point
                  * to replace the selected auto complete suggestion.
                  */
-                var token = self.editor.getTokenAt(cur), start, end, search;
+                var token = self.editor.getTokenAt(cur),
+                  start, end, search;
                 if (token.end > cur.ch) {
                   token.end = cur.ch;
                   token.string = token.string.slice(0, cur.ch - token.start);
@@ -382,7 +393,7 @@ define('tools.querytool', [
                   end = token.end;
                 } else {
                   start = end = cur.ch;
-                  search = "";
+                  search = '';
                 }
 
                 /*
@@ -390,79 +401,80 @@ define('tools.querytool', [
                  * started with "." or "`" else auto complete of code mirror
                  * will remove the "." when user select any suggestion.
                  */
-                if (search.charAt(0) == "." || search.charAt(0) == "``")
+                if (search.charAt(0) == '.' || search.charAt(0) == '``')
                   start += 1;
 
                 cb({
                   list: result,
-                  from: {line: self.current_line, ch: start},
-                  to: {line: self.current_line, ch: end}
+                  from: {
+                    line: self.current_line,
+                    ch: start,
+                  },
+                  to: {
+                    line: self.current_line,
+                    ch: end,
+                  },
                 });
-              }
+              },
             });
-          }.bind(ctx)
+          }.bind(ctx),
         };
       });
     },
 
     /* To prompt user for unsaved changes */
-    user_confirmation: function (panel, msg) {
+    user_confirmation: function(panel, msg) {
       // If there is anything to save then prompt user
       var that = this;
 
-      alertify.confirmSave || alertify.dialog('confirmSave', function () {
+      alertify.confirmSave || alertify.dialog('confirmSave', function() {
         return {
-          main: function (title, message) {
-            var content = '<div class="ajs-content">'
-              + gettext('The text has changed. Do you want to save changes?')
-              + '</div>';
+          main: function(title, message) {
             this.setHeader(title);
             this.setContent(message);
           },
-          setup: function () {
+          setup: function() {
             return {
-              buttons: [
-                {
-                  text: gettext('Save'),
-                  className: 'btn btn-primary',
-                }, {
-                  text: gettext('Don\'t save'),
-                  className: 'btn btn-danger',
-                }, {
-                  text: gettext('Cancel'),
-                  key: 27, // ESC
-                  invokeOnClose: true,
-                  className: 'btn btn-warning',
-                }
-              ],
+              buttons: [{
+                text: gettext('Save'),
+                className: 'btn btn-primary',
+              }, {
+                text: gettext('Don\'t save'),
+                className: 'btn btn-danger',
+              }, {
+                text: gettext('Cancel'),
+                key: 27, // ESC
+                invokeOnClose: true,
+                className: 'btn btn-warning',
+              }],
               focus: {
                 element: 0,
-                select: false
+                select: false,
               },
               options: {
                 maximizable: false,
-                resizable: false
-              }
+                resizable: false,
+              },
             };
           },
-          callback: function (closeEvent) {
+          callback: function(closeEvent) {
             switch (closeEvent.index) {
-              case 0: // Save
-                that.handler.close_on_save = true;
-                that.handler._save(that, that.handler);
-                break;
-              case 1: // Don't Save
-                that.handler.close_on_save = false;
-                that.handler.close();
-                break;
-              case 2: //Cancel
+            case 0: // Save
+              that.handler.close_on_save = true;
+              that.handler._save(that, that.handler);
+              break;
+            case 1: // Don't Save
+              that.handler.close_on_save = false;
+              that.handler.close();
+              break;
+            case 2: //Cancel
                 //Do nothing.
-                break;
+              break;
             }
-          }
+          },
         };
       });
-      alertify.confirmSave(gettext("Save changes?"), msg);
+      alertify.confirmSave(gettext('Save changes?'), msg);
       return false;
     },
 
@@ -524,7 +536,7 @@ define('tools.querytool', [
      */
 
     // This function is responsible to create and render the SlickGrid.
-    render_grid: function (collection, columns, is_editable, client_primary_key, rows_affected) {
+    render_grid: function(collection, columns, is_editable, client_primary_key, rows_affected) {
       var self = this;
 
       // This will work as data store and holds all the
@@ -535,7 +547,7 @@ define('tools.querytool', [
         staged_rows: {},
         deleted: {},
         updated_index: {},
-        added_index: {}
+        added_index: {},
       };
 
       // To store primary keys before they gets changed
@@ -550,29 +562,27 @@ define('tools.querytool', [
         self.handler.slickgrid.destroy();
       }
 
-        if(!_.isArray(collection) || !_.size(collection)) {
-          collection = [];
-        }
+      if (!_.isArray(collection) || !_.size(collection)) {
+        collection = [];
+      }
 
-        var grid_columns = [],
-          table_name;
-        var column_size = self.handler['col_size'],
-          query = self.handler.query,
-          // Extract table name from query
-          table_list = query.match(/select.*from\s+\w+\.*(\w+)/i);
+      var grid_columns = [],
+        table_name;
+      var column_size = self.handler['col_size'],
+        query = self.handler.query,
+        // Extract table name from query
+        table_list = query.match(/select.*from\s+\w+\.*(\w+)/i);
 
       if (!table_list) {
         table_name = SqlEditorUtils.getHash(query);
-      }
-      else {
+      } else {
         table_name = table_list[1];
       }
 
       self.handler['table_name'] = table_name;
       column_size[table_name] = column_size[table_name] || {};
 
-      var grid_width = $($('#editor-panel').find('.wcFrame')[1]).width();
-      _.each(columns, function (c) {
+      _.each(columns, function(c) {
         var options = {
           id: c.name,
           pos: c.pos,
@@ -583,7 +593,7 @@ define('tools.querytool', [
           column_type_internal: c.column_type_internal,
           not_null: c.not_null,
           has_default_val: c.has_default_val,
-          is_array: c.is_array
+          is_array: c.is_array,
         };
 
         // Get the columns width based on longer string among data type or
@@ -594,38 +604,36 @@ define('tools.querytool', [
         if (_.isUndefined(column_size[table_name][c.name])) {
           options['width'] = SqlEditorUtils.calculateColumnWidth(label);
           column_size[table_name][c.name] = options['width'];
-        }
-        else {
+        } else {
           options['width'] = column_size[table_name][c.name];
         }
         // If grid is editable then add editor else make it readonly
         if (c.cell == 'oid') {
           options['editor'] = null;
-        }
-        else if (c.cell == 'Json') {
-          options['editor'] = is_editable ? Slick.Editors.JsonText
-            : Slick.Editors.ReadOnlyJsonText;
+        } else if (c.cell == 'Json') {
+          options['editor'] = is_editable ? Slick.Editors.JsonText :
+            Slick.Editors.ReadOnlyJsonText;
           options['formatter'] = Slick.Formatters.JsonString;
         } else if (c.cell == 'number' ||
           $.inArray(c.type, ['oid', 'xid', 'real']) !== -1
         ) {
-          options['editor'] = is_editable ? Slick.Editors.CustomNumber
-            : Slick.Editors.ReadOnlyText;
+          options['editor'] = is_editable ? Slick.Editors.CustomNumber :
+            Slick.Editors.ReadOnlyText;
           options['formatter'] = Slick.Formatters.Numbers;
         } else if (c.cell == 'boolean') {
-          options['editor'] = is_editable ? Slick.Editors.Checkbox
-            : Slick.Editors.ReadOnlyCheckbox;
+          options['editor'] = is_editable ? Slick.Editors.Checkbox :
+            Slick.Editors.ReadOnlyCheckbox;
           options['formatter'] = Slick.Formatters.Checkmark;
         } else if (c.cell == 'binary') {
           // We do not support editing binary data in SQL editor and data grid.
-          options['formatter'] =  Slick.Formatters.Binary;
-        }else {
-          options['editor'] = is_editable ? Slick.Editors.pgText
-            : Slick.Editors.ReadOnlypgText;
+          options['formatter'] = Slick.Formatters.Binary;
+        } else {
+          options['editor'] = is_editable ? Slick.Editors.pgText :
+            Slick.Editors.ReadOnlypgText;
           options['formatter'] = Slick.Formatters.Text;
         }
 
-        grid_columns.push(options)
+        grid_columns.push(options);
       });
 
       var gridSelector = new GridSelector();
@@ -642,7 +650,7 @@ define('tools.querytool', [
         enableCellNavigation: true,
         enableColumnReorder: false,
         asyncEditorLoading: false,
-        autoEdit: false
+        autoEdit: false,
       };
 
       var $data_grid = self.$el.find('#datagrid');
@@ -656,8 +664,8 @@ define('tools.querytool', [
       // Add-on function which allow us to identify the faulty row after insert/update
       // and apply css accordingly
 
-      dataView.getItemMetadata = function (i) {
-        var res = {}, cssClass = '',
+      dataView.getItemMetadata = function(i) {
+        var cssClass = '',
           data_store = self.handler.data_store;
 
         if (_.has(self.handler, 'data_store')) {
@@ -677,15 +685,19 @@ define('tools.querytool', [
 
         // Disable rows having default values
         if (!_.isUndefined(self.handler.rows_to_disable) &&
-            self.handler.rows_to_disable.length > 0 &&
-            _.indexOf(self.handler.rows_to_disable, i) !== -1) {
+          self.handler.rows_to_disable.length > 0 &&
+          _.indexOf(self.handler.rows_to_disable, i) !== -1) {
           cssClass += ' disabled_row';
         }
 
-        return {'cssClasses': cssClass};
+        return {
+          'cssClasses': cssClass,
+        };
       };
 
-      grid.registerPlugin(new Slick.AutoTooltips({enableForHeaderCells: false}));
+      grid.registerPlugin(new Slick.AutoTooltips({
+        enableForHeaderCells: false,
+      }));
       grid.registerPlugin(new ActiveCellCapture());
       grid.setSelectionModel(new XCellSelectionModel());
       grid.registerPlugin(gridSelector);
@@ -698,7 +710,7 @@ define('tools.querytool', [
         selection: grid.getSelectionModel(),
         editor: self,
         client_primary_key: self.client_primary_key,
-        has_oids: self.handler.has_oids
+        has_oids: self.handler.has_oids,
       };
 
       self.handler.slickgrid = grid;
@@ -709,19 +721,19 @@ define('tools.querytool', [
           setStagedRows.bind(editor_data));
       }
 
-      grid.onColumnsResized.subscribe(function (e, args) {
+      grid.onColumnsResized.subscribe(function() {
         var columns = this.getColumns();
-        _.each(columns, function (col, key) {
+        _.each(columns, function(col) {
           var column_size = self.handler['col_size'];
           column_size[self.handler['table_name']][col['id']] = col['width'];
         });
       });
 
-      gridSelector.onBeforeGridSelectAll.subscribe(function (e, args) {
+      gridSelector.onBeforeGridSelectAll.subscribe(function(e, args) {
         if (self.handler.has_more_rows) {
           // this will prevent selection un-till we load all data
           e.stopImmediatePropagation();
-          self.fetch_next_all(function () {
+          self.fetch_next_all(function() {
             // since we've stopped event propagation we need to
             // trigger onGridSelectAll manually with new event data.
             gridSelector.onGridSelectAll.notify(args, new Slick.EventData());
@@ -729,11 +741,11 @@ define('tools.querytool', [
         }
       });
 
-      gridSelector.onBeforeGridColumnSelectAll.subscribe(function (e, args) {
+      gridSelector.onBeforeGridColumnSelectAll.subscribe(function(e, args) {
         if (self.handler.has_more_rows) {
           // this will prevent selection un-till we load all data
           e.stopImmediatePropagation();
-          self.fetch_next_all(function () {
+          self.fetch_next_all(function() {
             // since we've stopped event propagation we need to
             // trigger onGridColumnSelectAll manually with new event data.
             gridSelector.onGridColumnSelectAll.notify(args, new Slick.EventData());
@@ -742,20 +754,20 @@ define('tools.querytool', [
       });
 
       // listen for row count change.
-      dataView.onRowCountChanged.subscribe(function (e, args) {
+      dataView.onRowCountChanged.subscribe(function() {
         grid.updateRowCount();
         grid.render();
       });
 
       // listen for rows change.
-      dataView.onRowsChanged.subscribe(function (e, args) {
+      dataView.onRowsChanged.subscribe(function(e, args) {
         grid.invalidateRows(args.rows);
         grid.render();
       });
 
       // Listener function which will be called before user updates existing cell
       // This will be used to collect primary key for that row
-      grid.onBeforeEditCell.subscribe(function (e, args) {
+      grid.onBeforeEditCell.subscribe(function(e, args) {
         if (args.column.column_type_internal == 'bytea' ||
           args.column.column_type_internal == 'bytea[]') {
           return false;
@@ -773,7 +785,7 @@ define('tools.querytool', [
         if (self.handler.can_edit && before_data && self.client_primary_key in before_data) {
           var _pk = before_data[self.client_primary_key],
             _keys = self.handler.primary_keys,
-            current_pk = {}, each_pk_key = {};
+            current_pk = {};
 
           // If already have primary key data then no need to go ahead
           if (_pk in self.handler.primary_keys_data) {
@@ -781,23 +793,22 @@ define('tools.querytool', [
           }
 
           // Fetch primary keys for the row before they gets modified
-          var _columns = self.handler.columns;
-          _.each(_keys, function (value, key) {
+          _.each(_keys, function(value, key) {
             current_pk[key] = before_data[key];
           });
           // Place it in main variable for later use
-          self.handler.primary_keys_data[_pk] = current_pk
+          self.handler.primary_keys_data[_pk] = current_pk;
         }
       });
 
-      grid.onKeyDown.subscribe(function (event, args) {
+      grid.onKeyDown.subscribe(function(event, args) {
         var KEY_A = 65;
         var modifiedKey = event.keyCode;
         var isModifierDown = event.ctrlKey || event.metaKey;
         // Intercept Ctrl/Cmd + A key board event.
         // As we might want to load all rows before selecting all.
         if (isModifierDown && modifiedKey == KEY_A && self.handler.has_more_rows) {
-          self.fetch_next_all(function () {
+          self.fetch_next_all(function() {
             handleQueryOutputKeyboardEvent(event, args);
           });
         } else {
@@ -811,23 +822,30 @@ define('tools.querytool', [
           }
 
           // Get CSV options from preferences cache
-          args.grid.CSVOptions.quoting = _.findWhere(pref_cache, {'module': 'sqleditor', 'name': 'results_grid_quoting'}).value;
-          args.grid.CSVOptions.quote_char = _.findWhere(pref_cache, {'module': 'sqleditor', 'name': 'results_grid_quote_char'}).value;
-          args.grid.CSVOptions.field_separator =  _.findWhere(pref_cache, {'module': 'sqleditor', 'name': 'results_grid_field_separator'}).value;
+          args.grid.CSVOptions.quoting = _.findWhere(pref_cache, {
+            'module': 'sqleditor',
+            'name': 'results_grid_quoting',
+          }).value;
+          args.grid.CSVOptions.quote_char = _.findWhere(pref_cache, {
+            'module': 'sqleditor',
+            'name': 'results_grid_quote_char',
+          }).value;
+          args.grid.CSVOptions.field_separator = _.findWhere(pref_cache, {
+            'module': 'sqleditor',
+            'name': 'results_grid_field_separator',
+          }).value;
 
           handleQueryOutputKeyboardEvent(event, args);
         }
       });
 
       // Listener function which will be called when user updates existing rows
-      grid.onCellChange.subscribe(function (e, args) {
+      grid.onCellChange.subscribe(function(e, args) {
         // self.handler.data_store.updated will holds all the updated data
         var changed_column = args.grid.getColumns()[args.cell].field,
-          updated_data = args.item[changed_column],                   // New value for current field
-          _pk = args.item[self.client_primary_key] || null,           // Unique key to identify row
-          has_oids = self.handler.has_oids || null,           // Unique key to identify row
-          column_data = {},
-          _type;
+          updated_data = args.item[changed_column], // New value for current field
+          _pk = args.item[self.client_primary_key] || null, // Unique key to identify row
+          column_data = {};
 
         // Access to row/cell value after a cell is changed.
         // The purpose is to remove row_id from temp_new_row
@@ -836,16 +854,16 @@ define('tools.querytool', [
         var grid = args.grid,
           row_data = grid.getDataItem(args.row),
           is_primary_key = self.primary_keys &&
-            _.all(
-              _.values(
-                _.pick(
-                  row_data, self.primary_keys
-                )
-              ),
-              function (val) {
-                return val != undefined
-              }
-            );
+          _.all(
+            _.values(
+              _.pick(
+                row_data, self.primary_keys
+              )
+            ),
+            function(val) {
+              return val != undefined;
+            }
+          );
 
         // temp_new_rows is available only for view data.
         if (is_primary_key && self.handler.temp_new_rows) {
@@ -872,25 +890,27 @@ define('tools.querytool', [
               self.handler.data_store.updated[_pk]['data'],
               column_data
             );
-            self.handler.data_store.updated[_pk]['err'] = false
+            self.handler.data_store.updated[_pk]['err'] = false;
           } else {
             // First updated data for this primary key
             self.handler.data_store.updated[_pk] = {
-              'err': false, 'data': column_data,
-              'primary_keys': self.handler.primary_keys_data[_pk]
+              'err': false,
+              'data': column_data,
+              'primary_keys': self.handler.primary_keys_data[_pk],
             };
             self.handler.data_store.updated_index[args.row] = _pk;
           }
         }
         // Enable save button
-        $("#btn-save").prop('disabled', false);
+        $('#btn-save').prop('disabled', false);
       }.bind(editor_data));
 
       // Listener function which will be called when user adds new rows
-      grid.onAddNewRow.subscribe(function (e, args) {
+      grid.onAddNewRow.subscribe(function(e, args) {
         // self.handler.data_store.added will holds all the newly added rows/data
         var column = args.column,
-          item = args.item, data_length = this.grid.getDataLength(),
+          item = args.item,
+          data_length = this.grid.getDataLength(),
           _key = (self.client_primary_key_counter++).toString(),
           dataView = this.grid.getData();
 
@@ -905,20 +925,25 @@ define('tools.querytool', [
         }
 
         dataView.addItem(item);
-        self.handler.data_store.added[_key] = {'err': false, 'data': item};
+        self.handler.data_store.added[_key] = {
+          'err': false,
+          'data': item,
+        };
         self.handler.data_store.added_index[data_length] = _key;
         // Fetch data type & add it for the column
         var temp = {};
-        temp[column.name] = _.where(this.columns, {pos: column.pos})[0]['type'];
+        temp[column.name] = _.where(this.columns, {
+          pos: column.pos,
+        })[0]['type'];
         grid.updateRowCount();
         grid.render();
 
         // Enable save button
-        $("#btn-save").prop('disabled', false);
+        $('#btn-save').prop('disabled', false);
       }.bind(editor_data));
 
       // Listen grid viewportChanged event to load next chunk of data.
-      grid.onViewportChanged.subscribe(function (e, args) {
+      grid.onViewportChanged.subscribe(function(e, args) {
         var rendered_range = args.grid.getRenderedRange(),
           data_len = args.grid.getDataLength();
         // start fetching next batch of records before reaching to bottom.
@@ -929,7 +954,7 @@ define('tools.querytool', [
       });
 
       // Resize SlickGrid when window resize
-      $(window).resize(function () {
+      $(window).resize(function() {
         // Resize grid only when 'Data Output' panel is visible.
         if (self.data_output_panel.isVisible()) {
           self.grid_resize(grid);
@@ -937,7 +962,7 @@ define('tools.querytool', [
       });
 
       // Resize SlickGrid when output Panel resize
-      self.data_output_panel.on(wcDocker.EVENT.RESIZE_ENDED, function () {
+      self.data_output_panel.on(wcDocker.EVENT.RESIZE_ENDED, function() {
         // Resize grid only when 'Data Output' panel is visible.
         if (self.data_output_panel.isVisible()) {
           self.grid_resize(grid);
@@ -945,7 +970,7 @@ define('tools.querytool', [
       });
 
       // Resize SlickGrid when output Panel gets focus
-      self.data_output_panel.on(wcDocker.EVENT.VISIBILITY_CHANGED, function () {
+      self.data_output_panel.on(wcDocker.EVENT.VISIBILITY_CHANGED, function() {
         // Resize grid only if output panel is visible
         if (self.data_output_panel.isVisible())
           self.grid_resize(grid);
@@ -955,7 +980,7 @@ define('tools.querytool', [
         // Convert to dict from 2darray
         var item = {};
         for (var j = 1; j < grid_columns.length; j++) {
-          item[grid_columns[j]['field']] = collection[i][grid_columns[j]['pos']]
+          item[grid_columns[j]['field']] = collection[i][grid_columns[j]['pos']];
         }
 
         item[self.client_primary_key] = (self.client_primary_key_counter++).toString();
@@ -963,47 +988,53 @@ define('tools.querytool', [
       }
       dataView.setItems(collection, self.client_primary_key);
     },
-    fetch_next_all: function (cb) {
+    fetch_next_all: function(cb) {
       this.fetch_next(true, cb);
     },
-    fetch_next: function (fetch_all, cb) {
-      var self = this, url = '';
+    fetch_next: function(fetch_all, cb) {
+      var self = this,
+        url = '';
 
       // This will prevent fetch operation if previous fetch operation is
       // already in progress.
       self.handler.fetching_rows = true;
 
-      $("#btn-flash").prop('disabled', true);
+      $('#btn-flash').prop('disabled', true);
 
       if (fetch_all) {
         self.handler.trigger(
           'pgadmin-sqleditor:loading-icon:show',
           gettext('Fetching all records...')
         );
-        url = url_for('sqleditor.fetch_all', {'trans_id': self.transId, 'fetch_all': 1});
+        url = url_for('sqleditor.fetch_all', {
+          'trans_id': self.transId,
+          'fetch_all': 1,
+        });
       } else {
-        url = url = url_for('sqleditor.fetch', {'trans_id': self.transId});
+        url = url = url_for('sqleditor.fetch', {
+          'trans_id': self.transId,
+        });
       }
 
       $.ajax({
         url: url,
         method: 'GET',
-        success: function (res) {
+        success: function(res) {
           self.handler.has_more_rows = res.data.has_more_rows;
-          $("#btn-flash").prop('disabled', false);
+          $('#btn-flash').prop('disabled', false);
           self.handler.trigger('pgadmin-sqleditor:loading-icon:hide');
           self.update_grid_data(res.data.result);
           self.handler.fetching_rows = false;
-          if (typeof cb == "function") {
+          if (typeof cb == 'function') {
             cb();
           }
         },
-        error: function (e) {
-          $("#btn-flash").prop('disabled', false);
+        error: function(e) {
+          $('#btn-flash').prop('disabled', false);
           self.handler.trigger('pgadmin-sqleditor:loading-icon:hide');
           self.handler.has_more_rows = false;
           self.handler.fetching_rows = false;
-          if (typeof cb == "function") {
+          if (typeof cb == 'function') {
             cb();
           }
           if (e.readyState == 0) {
@@ -1012,18 +1043,18 @@ define('tools.querytool', [
             );
             return;
           }
-        }
+        },
       });
     },
 
-    update_grid_data: function (data) {
+    update_grid_data: function(data) {
       this.dataView.beginUpdate();
 
       for (var i = 0; i < data.length; i++) {
         // Convert 2darray to dict.
         var item = {};
         for (var j = 1; j < this.grid_columns.length; j++) {
-          item[this.grid_columns[j]['field']] = data[i][this.grid_columns[j]['pos']]
+          item[this.grid_columns[j]['field']] = data[i][this.grid_columns[j]['pos']];
         }
 
         item[this.client_primary_key] = (this.client_primary_key_counter++).toString();
@@ -1034,7 +1065,7 @@ define('tools.querytool', [
     },
 
     /* This function is responsible to render output grid */
-    grid_resize: function (grid) {
+    grid_resize: function(grid) {
       var prev_height = $('#datagrid').height(),
         h = $($('#editor-panel').find('.wcFrame')[1]).height() - 35,
         prev_viewport = grid.getViewport(),
@@ -1043,7 +1074,9 @@ define('tools.querytool', [
 
       // Apply css only if necessary, To avoid DOM operation
       if (prev_height != h) {
-        $('#datagrid').css({'height': h + 'px'});
+        $('#datagrid').css({
+          'height': h + 'px',
+        });
       }
 
       grid.resizeCanvas();
@@ -1051,13 +1084,13 @@ define('tools.querytool', [
       /*
        * If there is an active cell from user then we have to go to that cell
        */
-      if(prev_cell) {
+      if (prev_cell) {
         grid.scrollCellIntoView(prev_cell.row, prev_cell.cell);
       }
 
       // If already displaying from first row
       if (prev_viewport.top == prev_viewport_rows.top) {
-        return
+        return;
       }
       // if user has scroll to the end/last row
       else if (prev_viewport.bottom - 2 == prev_viewport_rows.bottom) {
@@ -1070,7 +1103,7 @@ define('tools.querytool', [
     /* This function is responsible to create and render the
      * new backgrid for the history tab.
      */
-    render_history_grid: function () {
+    render_history_grid: function() {
       var self = this;
 
       self.history_collection = new HistoryBundle.HistoryCollection([]);
@@ -1079,19 +1112,19 @@ define('tools.querytool', [
       var historyCollectionReactElement = React.createElement(
         queryHistory.QueryHistory, {
           historyCollection: self.history_collection,
-          ref: function (component) {
+          ref: function(component) {
             historyComponent = component;
           },
         });
       ReactDOM.render(historyCollectionReactElement, $('#history_grid')[0]);
 
-      self.history_panel.on(wcDocker.EVENT.VISIBILITY_CHANGED, function () {
+      self.history_panel.on(wcDocker.EVENT.VISIBILITY_CHANGED, function() {
         historyComponent.refocus();
       });
     },
 
     // Callback function for Add New Row button click.
-    on_delete: function () {
+    on_delete: function() {
       var self = this;
 
       // Trigger the addrow signal to the SqlEditorController class
@@ -1102,7 +1135,7 @@ define('tools.querytool', [
       );
     },
 
-    _stopEventPropogation: function (ev) {
+    _stopEventPropogation: function(ev) {
       ev = ev || window.event;
       ev.cancelBubble = true;
       ev.stopPropagation();
@@ -1110,7 +1143,7 @@ define('tools.querytool', [
       ev.preventDefault();
     },
 
-    _closeDropDown: function (ev) {
+    _closeDropDown: function(ev) {
       var target = ev && (ev.currentTarget || ev.target);
       if (target) {
         $(target).closest('.open').removeClass('open').find('.dropdown-backdrop').remove();
@@ -1118,7 +1151,7 @@ define('tools.querytool', [
     },
 
     // Callback function for Save button click.
-    on_save: function (ev) {
+    on_save: function(ev) {
       var self = this;
 
       this._stopEventPropogation(ev);
@@ -1134,7 +1167,7 @@ define('tools.querytool', [
     },
 
     // Callback function for Save button click.
-    on_save_as: function (ev) {
+    on_save_as: function(ev) {
       var self = this;
 
       this._stopEventPropogation(ev);
@@ -1151,70 +1184,72 @@ define('tools.querytool', [
     },
 
     // Callback function for the find button click.
-    on_find: function (ev) {
-      var self = this, sql;
+    on_find: function(ev) {
+      var self = this;
       this._stopEventPropogation(ev);
       this._closeDropDown(ev);
 
-      self.query_tool_obj.execCommand("find");
+      self.query_tool_obj.execCommand('find');
     },
 
     // Callback function for the find next button click.
-    on_find_next: function (ev) {
-      var self = this, sql;
+    on_find_next: function(ev) {
+      var self = this;
       this._stopEventPropogation(ev);
       this._closeDropDown(ev);
 
-      self.query_tool_obj.execCommand("findNext");
+      self.query_tool_obj.execCommand('findNext');
     },
 
     // Callback function for the find previous button click.
-    on_find_previous: function (ev) {
-      var self = this, sql;
+    on_find_previous: function(ev) {
+      var self = this;
       this._stopEventPropogation(ev);
       this._closeDropDown(ev);
 
-      self.query_tool_obj.execCommand("findPrev");
+      self.query_tool_obj.execCommand('findPrev');
     },
 
     // Callback function for the replace button click.
-    on_replace: function (ev) {
-      var self = this, sql;
+    on_replace: function(ev) {
+      var self = this;
       this._stopEventPropogation(ev);
       this._closeDropDown(ev);
 
-      self.query_tool_obj.execCommand("replace");
+      self.query_tool_obj.execCommand('replace');
     },
 
     // Callback function for the replace all button click.
-    on_replace_all: function (ev) {
-      var self = this, sql;
+    on_replace_all: function(ev) {
+      var self = this;
       this._stopEventPropogation(ev);
       this._closeDropDown(ev);
 
-      self.query_tool_obj.execCommand("replaceAll");
+      self.query_tool_obj.execCommand('replaceAll');
     },
 
     // Callback function for the find persistent button click.
-    on_find_persistent: function (ev) {
-      var self = this, sql;
+    on_find_persistent: function(ev) {
+      var self = this;
+
       this._stopEventPropogation(ev);
       this._closeDropDown(ev);
 
-      self.query_tool_obj.execCommand("findPersistent");
+      self.query_tool_obj.execCommand('findPersistent');
     },
 
     // Callback function for the jump button click.
-    on_jump: function (ev) {
-      var self = this, sql;
+    on_jump: function(ev) {
+      var self = this;
+
       this._stopEventPropogation(ev);
       this._closeDropDown(ev);
 
-      self.query_tool_obj.execCommand("jumpToLine");
+      self.query_tool_obj.execCommand('jumpToLine');
     },
 
     // Callback function for filter button click.
-    on_show_filter: function () {
+    on_show_filter: function() {
       var self = this;
 
       // Trigger the show_filter signal to the SqlEditorController class
@@ -1226,7 +1261,7 @@ define('tools.querytool', [
     },
 
     // Callback function for include filter button click.
-    on_include_filter: function (ev) {
+    on_include_filter: function(ev) {
       var self = this;
 
       this._stopEventPropogation(ev);
@@ -1241,7 +1276,7 @@ define('tools.querytool', [
     },
 
     // Callback function for exclude filter button click.
-    on_exclude_filter: function (ev) {
+    on_exclude_filter: function(ev) {
       var self = this;
 
       this._stopEventPropogation(ev);
@@ -1256,7 +1291,7 @@ define('tools.querytool', [
     },
 
     // Callback function for remove filter button click.
-    on_remove_filter: function (ev) {
+    on_remove_filter: function(ev) {
       var self = this;
 
       this._stopEventPropogation(ev);
@@ -1271,7 +1306,7 @@ define('tools.querytool', [
     },
 
     // Callback function for ok button click.
-    on_apply: function () {
+    on_apply: function() {
       var self = this;
 
       // Trigger the apply_filter signal to the SqlEditorController class
@@ -1283,15 +1318,15 @@ define('tools.querytool', [
     },
 
     // Callback function for cancel button click.
-    on_cancel: function () {
+    on_cancel: function() {
       $('#filter').addClass('hidden');
       $('#editor-panel').removeClass('sql-editor-busy-fetching');
     },
 
     // Callback function for copy button click.
-    on_copy_row: function () {
+    on_copy_row: function() {
       var self = this,
-          pref_cache = undefined;
+        pref_cache = undefined;
       self.grid.CSVOptions = {};
 
       if (self.handler.is_new_browser_tab) {
@@ -1301,9 +1336,18 @@ define('tools.querytool', [
       }
 
       // Get CSV options from preferences cache
-      self.grid.CSVOptions.quoting = _.findWhere(pref_cache, {'module': 'sqleditor', 'name': 'results_grid_quoting'}).value;
-      self.grid.CSVOptions.quote_char = _.findWhere(pref_cache, {'module': 'sqleditor', 'name': 'results_grid_quote_char'}).value;
-      self.grid.CSVOptions.field_separator =  _.findWhere(pref_cache, {'module': 'sqleditor', 'name': 'results_grid_field_separator'}).value;
+      self.grid.CSVOptions.quoting = _.findWhere(pref_cache, {
+        'module': 'sqleditor',
+        'name': 'results_grid_quoting',
+      }).value;
+      self.grid.CSVOptions.quote_char = _.findWhere(pref_cache, {
+        'module': 'sqleditor',
+        'name': 'results_grid_quote_char',
+      }).value;
+      self.grid.CSVOptions.field_separator = _.findWhere(pref_cache, {
+        'module': 'sqleditor',
+        'name': 'results_grid_field_separator',
+      }).value;
 
       // Trigger the copy signal to the SqlEditorController class
       self.handler.trigger(
@@ -1315,7 +1359,7 @@ define('tools.querytool', [
     },
 
     // Callback function for paste button click.
-    on_paste_row: function () {
+    on_paste_row: function() {
       var self = this;
 
       // Trigger the paste signal to the SqlEditorController class
@@ -1327,7 +1371,7 @@ define('tools.querytool', [
     },
 
     // Callback function for the change event of combo box
-    on_limit_change: function () {
+    on_limit_change: function() {
       var self = this;
 
       // Trigger the limit signal to the SqlEditorController class
@@ -1339,12 +1383,12 @@ define('tools.querytool', [
     },
 
     // Callback function for the flash button click.
-    on_flash: function () {
+    on_flash: function() {
       queryToolActions.executeQuery(this.handler);
     },
 
     // Callback function for the cancel query button click.
-    on_cancel_query: function () {
+    on_cancel_query: function() {
       var self = this;
 
       // Trigger the cancel-query signal to the SqlEditorController class
@@ -1356,21 +1400,21 @@ define('tools.querytool', [
     },
 
     // Callback function for the line comment code
-    on_comment_line_code: function () {
+    on_comment_line_code: function() {
       queryToolActions.commentLineCode(this.handler);
     },
 
     // Callback function for the line uncomment code
-    on_uncomment_line_code: function () {
+    on_uncomment_line_code: function() {
       queryToolActions.uncommentLineCode(this.handler);
     },
 
     // Callback function for the block comment/uncomment code
-    on_toggle_comment_block_code: function () {
+    on_toggle_comment_block_code: function() {
       queryToolActions.commentBlockCode(this.handler);
     },
 
-    on_indent_code: function () {
+    on_indent_code: function() {
       var self = this;
       // Trigger the comment signal to the SqlEditorController class
       self.handler.trigger(
@@ -1380,7 +1424,7 @@ define('tools.querytool', [
       );
     },
 
-    on_unindent_code: function () {
+    on_unindent_code: function() {
       var self = this;
       // Trigger the comment signal to the SqlEditorController class
       self.handler.trigger(
@@ -1391,8 +1435,8 @@ define('tools.querytool', [
     },
 
     // Callback function for the clear button click.
-    on_clear: function (ev) {
-      var self = this, sql;
+    on_clear: function(ev) {
+      var self = this;
       this._stopEventPropogation(ev);
       this._closeDropDown(ev);
 
@@ -1401,23 +1445,26 @@ define('tools.querytool', [
        */
       if (self.handler.is_query_changed) {
         alertify.confirm(
-          gettext("Unsaved changes"),
-          gettext("Are you sure you wish to discard the current changes?"),
-          function () {
+          gettext('Unsaved changes'),
+          gettext('Are you sure you wish to discard the current changes?'),
+          function() {
             // Do nothing as user do not want to save, just continue
             self.query_tool_obj.setValue('');
           },
-          function () {
+          function() {
             return true;
           }
-        ).set('labels', {ok: 'Yes', cancel: 'No'});
+        ).set('labels', {
+          ok: 'Yes',
+          cancel: 'No',
+        });
       } else {
         self.query_tool_obj.setValue('');
       }
     },
 
     // Callback function for the clear history button click.
-    on_clear_history: function (ev) {
+    on_clear_history: function(ev) {
       var self = this;
       this._stopEventPropogation(ev);
       this._closeDropDown(ev);
@@ -1426,21 +1473,24 @@ define('tools.querytool', [
         return;
       }
 
-      alertify.confirm(gettext("Clear history"),
-        gettext("Are you sure you wish to clear the history?"),
-        function () {
+      alertify.confirm(gettext('Clear history'),
+        gettext('Are you sure you wish to clear the history?'),
+        function() {
           if (self.history_collection) {
             self.history_collection.reset();
           }
         },
-        function () {
+        function() {
           return true;
         }
-      ).set('labels', {ok: 'Yes', cancel: 'No'});
+      ).set('labels', {
+        ok: 'Yes',
+        cancel: 'No',
+      });
     },
 
     // Callback function for the auto commit button click.
-    on_auto_commit: function (ev) {
+    on_auto_commit: function(ev) {
       var self = this;
 
       this._stopEventPropogation(ev);
@@ -1454,7 +1504,7 @@ define('tools.querytool', [
     },
 
     // Callback function for the auto rollback button click.
-    on_auto_rollback: function (ev) {
+    on_auto_rollback: function(ev) {
       var self = this;
 
       this._stopEventPropogation(ev);
@@ -1468,7 +1518,7 @@ define('tools.querytool', [
     },
 
     // Callback function for explain button click.
-    on_explain: function (event) {
+    on_explain: function(event) {
       this._stopEventPropogation(event);
       this._closeDropDown(event);
 
@@ -1476,7 +1526,7 @@ define('tools.querytool', [
     },
 
     // Callback function for explain analyze button click.
-    on_explain_analyze: function (event) {
+    on_explain_analyze: function(event) {
       this._stopEventPropogation(event);
       this._closeDropDown(event);
 
@@ -1484,7 +1534,7 @@ define('tools.querytool', [
     },
 
     // Callback function for explain option "verbose" button click
-    on_explain_verbose: function (ev) {
+    on_explain_verbose: function(ev) {
       var self = this;
 
       this._stopEventPropogation(ev);
@@ -1498,7 +1548,7 @@ define('tools.querytool', [
     },
 
     // Callback function for explain option "costs" button click
-    on_explain_costs: function (ev) {
+    on_explain_costs: function(ev) {
       var self = this;
 
       this._stopEventPropogation(ev);
@@ -1512,7 +1562,7 @@ define('tools.querytool', [
     },
 
     // Callback function for explain option "buffers" button click
-    on_explain_buffers: function (ev) {
+    on_explain_buffers: function(ev) {
       var self = this;
 
       this._stopEventPropogation(ev);
@@ -1526,7 +1576,7 @@ define('tools.querytool', [
     },
 
     // Callback function for explain option "timing" button click
-    on_explain_timing: function (ev) {
+    on_explain_timing: function(ev) {
       var self = this;
 
       this._stopEventPropogation(ev);
@@ -1539,12 +1589,12 @@ define('tools.querytool', [
       );
     },
 
-    do_not_close_menu: function (ev) {
+    do_not_close_menu: function(ev) {
       ev.stopPropagation();
     },
 
     // callback function for load file button click.
-    on_file_load: function (ev) {
+    on_file_load: function(ev) {
       var self = this;
 
       this._stopEventPropogation(ev);
@@ -1558,28 +1608,27 @@ define('tools.querytool', [
       );
     },
 
-    on_download: function () {
+    on_download: function() {
       queryToolActions.download(this.handler);
     },
 
-    keyAction: function (event) {
+    keyAction: function(event) {
       keyboardShortcuts.processEvent(this.handler, queryToolActions, event);
-    }
+    },
   });
 
   /* Defining controller class for data grid, which actually
    * perform the operations like executing the sql query, poll the result,
    * render the data in the grid, Save/Refresh the data etc...
    */
-  var SqlEditorController = function (container, options) {
+  var SqlEditorController = function() {
     this.initialize.apply(this, arguments);
   };
 
   _.extend(
     SqlEditorController.prototype,
-    Backbone.Events,
-    {
-      initialize: function (container, opts) {
+    Backbone.Events, {
+      initialize: function(container) {
         this.container = container;
       },
 
@@ -1587,7 +1636,7 @@ define('tools.querytool', [
        * call the render method of the grid view to render the backgrid
        * header and loading icon and start execution of the sql query.
        */
-      start: function (is_query_tool, editor_title, script_sql, is_new_browser_tab, server_type, prompt_save_changes) {
+      start: function(is_query_tool, editor_title, script_sql, is_new_browser_tab, server_type, prompt_save_changes) {
         var self = this;
 
         self.is_query_tool = is_query_tool;
@@ -1610,7 +1659,7 @@ define('tools.querytool', [
 
         self.gridView = new SQLEditorView({
           el: self.container,
-          handler: self
+          handler: self,
         });
         self.transId = self.gridView.transId = self.container.data('transId');
 
@@ -1659,10 +1708,9 @@ define('tools.querytool', [
           if (script_sql && script_sql !== '') {
             self.gridView.query_tool_obj.setValue(script_sql);
           }
-        }
-        else {
+        } else {
           // Disable codemirror by setting cursor to nocursor and background to dark.
-          self.gridView.query_tool_obj.setOption("readOnly", 'nocursor');
+          self.gridView.query_tool_obj.setOption('readOnly', 'nocursor');
           var cm = self.gridView.query_tool_obj.getWrapperElement();
           if (cm) {
             cm.className += ' bg-gray-1 opacity-5';
@@ -1674,33 +1722,36 @@ define('tools.querytool', [
 
       // This function checks if there is any dirty data in the grid before
       // it executes the sql query
-      execute_data_query: function () {
+      execute_data_query: function() {
         var self = this;
 
         // Check if the data grid has any changes before running query
         if (_.has(self, 'data_store') &&
-          ( _.size(self.data_store.added) ||
-          _.size(self.data_store.updated) ||
-          _.size(self.data_store.deleted))
+          (_.size(self.data_store.added) ||
+            _.size(self.data_store.updated) ||
+            _.size(self.data_store.deleted))
         ) {
-          alertify.confirm(gettext("Unsaved changes"),
-            gettext("The data has been modified, but not saved. Are you sure you wish to discard the changes?"),
-            function () {
+          alertify.confirm(gettext('Unsaved changes'),
+            gettext('The data has been modified, but not saved. Are you sure you wish to discard the changes?'),
+            function() {
               // Do nothing as user do not want to save, just continue
               self._run_query();
             },
-            function () {
+            function() {
               // Stop, User wants to save
               return true;
             }
-          ).set('labels', {ok: 'Yes', cancel: 'No'});
+          ).set('labels', {
+            ok: 'Yes',
+            cancel: 'No',
+          });
         } else {
           self._run_query();
         }
       },
 
       // This function makes the ajax call to execute the sql query.
-      _run_query: function () {
+      _run_query: function() {
         var self = this;
         self.query_start_time = new Date();
         self.rows_affected = 0;
@@ -1714,20 +1765,22 @@ define('tools.querytool', [
 
         self.trigger(
           'pgadmin-sqleditor:loading-icon:show',
-          gettext("Initializing query execution.")
+          gettext('Initializing query execution.')
         );
 
-        $("#btn-flash").prop('disabled', true);
+        $('#btn-flash').prop('disabled', true);
 
         self.trigger(
           'pgadmin-sqleditor:loading-icon:message',
-          gettext("Waiting for the query execution to complete...")
+          gettext('Waiting for the query execution to complete...')
         );
 
         $.ajax({
-          url: url_for('sqleditor.view_data_start', {'trans_id': self.transId}),
+          url: url_for('sqleditor.view_data_start', {
+            'trans_id': self.transId,
+          }),
           method: 'GET',
-          success: function (res) {
+          success: function(res) {
             if (res.data.status) {
 
               self.can_edit = res.data.can_edit;
@@ -1747,34 +1800,32 @@ define('tools.querytool', [
                 $('#btn-filter-dropdown').removeClass('btn-default');
                 $('#btn-filter').addClass('btn-warning');
                 $('#btn-filter-dropdown').addClass('btn-warning');
-              }
-              else {
+              } else {
                 $('#btn-filter').removeClass('btn-warning');
                 $('#btn-filter-dropdown').removeClass('btn-warning');
                 $('#btn-filter').addClass('btn-default');
                 $('#btn-filter-dropdown').addClass('btn-default');
               }
-              $("#btn-save").prop('disabled', true);
-              $("#btn-file-menu-dropdown").prop('disabled', true);
-              $("#btn-copy-row").prop('disabled', true);
-              $("#btn-paste-row").prop('disabled', true);
+              $('#btn-save').prop('disabled', true);
+              $('#btn-file-menu-dropdown').prop('disabled', true);
+              $('#btn-copy-row').prop('disabled', true);
+              $('#btn-paste-row').prop('disabled', true);
 
               // Set the combo box value
-              $(".limit").val(res.data.limit);
+              $('.limit').val(res.data.limit);
 
               // If status is True then poll the result.
               self._poll();
-            }
-            else {
+            } else {
               self.trigger('pgadmin-sqleditor:loading-icon:hide');
               self.update_msg_history(false, res.data.result);
             }
           },
-          error: function (e) {
+          error: function(e) {
             self.trigger('pgadmin-sqleditor:loading-icon:hide');
             if (e.readyState == 0) {
               self.update_msg_history(false,
-                gettext("Not connected to the server or the connection to the server has been closed.")
+                gettext('Not connected to the server or the connection to the server has been closed.')
               );
               return;
             }
@@ -1785,41 +1836,41 @@ define('tools.querytool', [
               msg = e.responseJSON.errormsg;
 
             self.update_msg_history(false, msg);
-          }
+          },
         });
       },
 
       // This is a wrapper to call_render function
       // We need this because we have separated columns route & result route
       // We need to combine both result here in wrapper before rendering grid
-      call_render_after_poll: function (res) {
+      call_render_after_poll: function(res) {
         var self = this;
         self.query_end_time = new Date();
         self.rows_affected = res.rows_affected,
           self.has_more_rows = res.has_more_rows;
 
-          /* If no column information is available it means query
-             runs successfully with no result to display. In this
-             case no need to call render function.
-          */
-          if (res.colinfo != null)
-            self._render(res);
-          else {
-            // Show message in message and history tab in case of query tool
-            self.total_time = self.get_query_run_time(self.query_start_time, self.query_end_time);
-            var msg = S(gettext("Query returned successfully in %s.")).sprintf(self.total_time).value();
-            res.result += "\n\n" + msg;
-            self.update_msg_history(true, res.result, false);
-            // Display the notifier if the timeout is set to >= 0
-            if (self.info_notifier_timeout >= 0) {
-              alertify.success(msg, self.info_notifier_timeout);
-            }
+        /* If no column information is available it means query
+           runs successfully with no result to display. In this
+           case no need to call render function.
+           */
+        if (res.colinfo != null)
+          self._render(res);
+        else {
+          // Show message in message and history tab in case of query tool
+          self.total_time = self.get_query_run_time(self.query_start_time, self.query_end_time);
+          var msg = S(gettext('Query returned successfully in %s.')).sprintf(self.total_time).value();
+          res.result += '\n\n' + msg;
+          self.update_msg_history(true, res.result, false);
+          // Display the notifier if the timeout is set to >= 0
+          if (self.info_notifier_timeout >= 0) {
+            alertify.success(msg, self.info_notifier_timeout);
           }
+        }
 
         // Enable/Disable query tool button only if is_query_tool is true.
         if (self.is_query_tool) {
           self.disable_tool_buttons(false);
-          $("#btn-cancel-query").prop('disabled', true);
+          $('#btn-cancel-query').prop('disabled', true);
         }
         is_query_running = false;
         self.trigger('pgadmin-sqleditor:loading-icon:hide');
@@ -1831,57 +1882,56 @@ define('tools.querytool', [
        * till the status is 'Success' or 'NotConnected'. If status is
        * 'Success' then call the render method to render the data.
        */
-      _poll: function () {
+      _poll: function() {
         var self = this;
 
         setTimeout(
-          function () {
+          function() {
             $.ajax({
-              url: url_for('sqleditor.poll', {'trans_id': self.transId}),
+              url: url_for('sqleditor.poll', {
+                'trans_id': self.transId,
+              }),
               method: 'GET',
-              success: function (res) {
+              success: function(res) {
                 if (res.data.status === 'Success') {
                   self.trigger(
                     'pgadmin-sqleditor:loading-icon:message',
-                    gettext("Loading data from the database server and rendering...")
+                    gettext('Loading data from the database server and rendering...')
                   );
 
                   self.call_render_after_poll(res.data);
-                }
-                else if (res.data.status === 'Busy') {
+                } else if (res.data.status === 'Busy') {
                   // If status is Busy then poll the result by recursive call to the poll function
                   self._poll();
                   is_query_running = true;
                   if (res.data.result) {
                     self.update_msg_history(res.data.status, res.data.result, false);
                   }
-                }
-                else if (res.data.status === 'NotConnected') {
+                } else if (res.data.status === 'NotConnected') {
                   self.trigger('pgadmin-sqleditor:loading-icon:hide');
                   // Enable/Disable query tool button only if is_query_tool is true.
                   if (self.is_query_tool) {
                     self.disable_tool_buttons(false);
-                    $("#btn-cancel-query").prop('disabled', true);
+                    $('#btn-cancel-query').prop('disabled', true);
                   }
                   self.update_msg_history(false, res.data.result, true);
-                }
-                else if (res.data.status === 'Cancel') {
+                } else if (res.data.status === 'Cancel') {
                   self.trigger('pgadmin-sqleditor:loading-icon:hide');
-                  self.update_msg_history(false, "Execution Cancelled!", true)
+                  self.update_msg_history(false, 'Execution Cancelled!', true);
                 }
               },
-              error: function (e) {
+              error: function(e) {
                 // Enable/Disable query tool button only if is_query_tool is true.
                 self.resetQueryHistoryObject(self);
                 self.trigger('pgadmin-sqleditor:loading-icon:hide');
                 if (self.is_query_tool) {
                   self.disable_tool_buttons(false);
-                  $("#btn-cancel-query").prop('disabled', true);
+                  $('#btn-cancel-query').prop('disabled', true);
                 }
 
                 if (e.readyState == 0) {
                   self.update_msg_history(false,
-                    gettext("Not connected to the server or the connection to the server has been closed.")
+                    gettext('Not connected to the server or the connection to the server has been closed.')
                   );
                   return;
                 }
@@ -1894,7 +1944,7 @@ define('tools.querytool', [
                 self.update_msg_history(false, msg);
                 // Highlight the error in the sql panel
                 self._highlight_error(msg);
-              }
+              },
             });
           }, self.POLL_FALLBACK_TIME());
       },
@@ -1903,10 +1953,10 @@ define('tools.querytool', [
        * create the Backbone PageableCollection and finally render
        * the data in the backgrid.
        */
-      _render: function (data) {
+      _render: function(data) {
         var self = this;
         self.colinfo = data.col_info;
-        self.primary_keys = (_.isEmpty(data.primary_keys) && data.has_oids)? data.oids : data.primary_keys;
+        self.primary_keys = (_.isEmpty(data.primary_keys) && data.has_oids) ? data.oids : data.primary_keys;
         self.client_primary_key = data.client_primary_key;
         self.cell_selected = false;
         self.selected_model = null;
@@ -1918,8 +1968,8 @@ define('tools.querytool', [
         /* If object don't have primary keys then set the
          * can_edit flag to false.
          */
-        if ((self.primary_keys === null || self.primary_keys === undefined
-          || _.size(self.primary_keys) === 0) && self.has_oids == false)
+        if ((self.primary_keys === null || self.primary_keys === undefined ||
+            _.size(self.primary_keys) === 0) && self.has_oids == false)
           self.can_edit = false;
         else
           self.can_edit = true;
@@ -1928,56 +1978,57 @@ define('tools.querytool', [
          * Filter and Limit buttons.
          */
         if (self.can_filter) {
-          $(".limit").prop('disabled', false);
-          $(".limit").addClass('limit-enabled');
-          $("#btn-filter").prop('disabled', false);
-          $("#btn-filter-dropdown").prop('disabled', false);
+          $('.limit').prop('disabled', false);
+          $('.limit').addClass('limit-enabled');
+          $('#btn-filter').prop('disabled', false);
+          $('#btn-filter-dropdown').prop('disabled', false);
         }
 
         // Initial settings for delete row, copy row and paste row buttons.
-        $("#btn-delete-row").prop('disabled', true);
+        $('#btn-delete-row').prop('disabled', true);
         // Do not disable save button in query tool
         if (!self.is_query_tool && !self.can_edit) {
-          $("#btn-save").prop('disabled', true);
-          $("#btn-file-menu-dropdown").prop('disabled', true);
+          $('#btn-save').prop('disabled', true);
+          $('#btn-file-menu-dropdown').prop('disabled', true);
         }
         if (!self.can_edit) {
-          $("#btn-delete-row").prop('disabled', true);
-          $("#btn-copy-row").prop('disabled', true);
-          $("#btn-paste-row").prop('disabled', true);
+          $('#btn-delete-row').prop('disabled', true);
+          $('#btn-copy-row').prop('disabled', true);
+          $('#btn-paste-row').prop('disabled', true);
         }
 
         // Fetch the columns metadata
         self._fetch_column_metadata.call(
-          self, data, function () {
+          self, data,
+          function() {
             var self = this;
 
             self.trigger(
               'pgadmin-sqleditor:loading-icon:message',
-              gettext("Loading data from the database server and rendering..."),
+              gettext('Loading data from the database server and rendering...'),
               self
             );
 
             // Show message in message and history tab in case of query tool
             self.total_time = self.get_query_run_time(self.query_start_time, self.query_end_time);
-            var msg1 = S(gettext("Successfully run. Total query runtime: %s.")).sprintf(self.total_time).value();
-            var msg2 = S(gettext("%s rows affected.")).sprintf(self.rows_affected).value();
+            var msg1 = S(gettext('Successfully run. Total query runtime: %s.')).sprintf(self.total_time).value();
+            var msg2 = S(gettext('%s rows affected.')).sprintf(self.rows_affected).value();
 
-              // Display the notifier if the timeout is set to >= 0
-              if (self.info_notifier_timeout >= 0) {
-                alertify.success(msg1 + ' ' + msg2, self.info_notifier_timeout);
-              }
+            // Display the notifier if the timeout is set to >= 0
+            if (self.info_notifier_timeout >= 0) {
+              alertify.success(msg1 + ' ' + msg2, self.info_notifier_timeout);
+            }
 
             var _msg = msg1 + '\n' + msg2;
 
 
-              // If there is additional messages from server then add it to message
-              if(!_.isNull(data.additional_messages) &&
-                    !_.isUndefined(data.additional_messages)) {
-                    _msg = data.additional_messages + '\n' + _msg;
-              }
+            // If there is additional messages from server then add it to message
+            if (!_.isNull(data.additional_messages) &&
+              !_.isUndefined(data.additional_messages)) {
+              _msg = data.additional_messages + '\n' + _msg;
+            }
 
-              self.update_msg_history(true,_msg, false);
+            self.update_msg_history(true, _msg, false);
 
             /* Add the data to the collection and render the grid.
              * In case of Explain draw the graph on explain panel
@@ -1996,7 +2047,7 @@ define('tools.querytool', [
               // start rendering the grid.
               self.gridView.data_output_panel.focus();
               setTimeout(
-                function () {
+                function() {
                   self.gridView.render_grid(
                     explain_data_array, self.columns, self.can_edit,
                     self.client_primary_key
@@ -2014,7 +2065,7 @@ define('tools.querytool', [
               // start rendering the grid.
               self.gridView.data_output_panel.focus();
               setTimeout(
-                function () {
+                function() {
                   self.gridView.render_grid(data.result, self.columns,
                     self.can_edit, self.client_primary_key, data.rows_affected);
                 }, 10
@@ -2023,31 +2074,30 @@ define('tools.querytool', [
 
             // Hide the loading icon
             self.trigger('pgadmin-sqleditor:loading-icon:hide');
-            $("#btn-flash").prop('disabled', false);
+            $('#btn-flash').prop('disabled', false);
           }.bind(self)
         );
       },
 
       // This function creates the columns as required by the backgrid
-      _fetch_column_metadata: function (data, cb) {
+      _fetch_column_metadata: function(data, cb) {
         var colinfo = data.colinfo,
           primary_keys = data.primary_keys,
-          result = data.result,
           columns = [],
           self = this;
         // Store pg_types in an array
         var pg_types = new Array();
-        _.each(data.types, function (r) {
+        _.each(data.types, function(r) {
           pg_types[r.oid] = [r.typname];
         });
 
         // Create columns required by slick grid to render
-        _.each(colinfo, function (c) {
+        _.each(colinfo, function(c) {
           var is_primary_key = false;
 
           // Check whether table have primary key
           if (_.size(primary_keys) > 0) {
-            _.each(primary_keys, function (value, key) {
+            _.each(primary_keys, function(value, key) {
               if (key === c.name)
                 is_primary_key = true;
             });
@@ -2065,7 +2115,7 @@ define('tools.querytool', [
             // have use casting so we will use type
             // returned by cast function
             pg_types[pg_types.length - 1][0] ?
-              pg_types[pg_types.length - 1][0] : 'unknown';
+            pg_types[pg_types.length - 1][0] : 'unknown';
 
           if (!is_primary_key)
             col_type += type;
@@ -2080,52 +2130,52 @@ define('tools.querytool', [
           }
           // Identify cell type of column.
           switch (type) {
-            case "oid":
-              col_cell = 'oid';
-              break;
-            case "json":
-            case "json[]":
-            case "jsonb":
-            case "jsonb[]":
-              col_cell = 'Json';
-              break;
-            case "smallint":
-            case "smallint[]":
-            case "integer":
-            case "integer[]":
-            case "bigint":
-            case "bigint[]":
-            case "decimal":
-            case "decimal[]":
-            case "numeric":
-            case "numeric[]":
-            case "real":
-            case "real[]":
-            case "double precision":
-            case "double precision[]":
-              col_cell = 'number';
-              break;
-            case "boolean":
-              col_cell = 'boolean';
-              break;
-            case "character":
-            case "character[]":
-            case "\"char\"":
-            case "\"char\"[]":
-            case "character varying":
-            case "character varying[]":
-              if (c.internal_size && c.internal_size >= 0 && c.internal_size != 65535) {
+          case 'oid':
+            col_cell = 'oid';
+            break;
+          case 'json':
+          case 'json[]':
+          case 'jsonb':
+          case 'jsonb[]':
+            col_cell = 'Json';
+            break;
+          case 'smallint':
+          case 'smallint[]':
+          case 'integer':
+          case 'integer[]':
+          case 'bigint':
+          case 'bigint[]':
+          case 'decimal':
+          case 'decimal[]':
+          case 'numeric':
+          case 'numeric[]':
+          case 'real':
+          case 'real[]':
+          case 'double precision':
+          case 'double precision[]':
+            col_cell = 'number';
+            break;
+          case 'boolean':
+            col_cell = 'boolean';
+            break;
+          case 'character':
+          case 'character[]':
+          case '"char"':
+          case '"char"[]':
+          case 'character varying':
+          case 'character varying[]':
+            if (c.internal_size && c.internal_size >= 0 && c.internal_size != 65535) {
                 // Update column type to display length on column header
-                col_type += ' (' + c.internal_size + ')';
-              }
-              col_cell = 'string';
-              break;
-            case "bytea":
-            case "bytea[]":
-              col_cell = 'binary';
-              break;
-            default:
-              col_cell = 'string';
+              col_type += ' (' + c.internal_size + ')';
+            }
+            col_cell = 'string';
+            break;
+          case 'bytea':
+          case 'bytea[]':
+            col_cell = 'binary';
+            break;
+          default:
+            col_cell = 'string';
           }
 
           column_label = c.display_name + '<br>' + col_type;
@@ -2143,7 +2193,7 @@ define('tools.querytool', [
               'type': type,
               'not_null': c.not_null,
               'has_default_val': c.has_default_val,
-              'is_array': array_type_bracket_index > -1 && array_type_bracket_index + 2 == type.length
+              'is_array': array_type_bracket_index > -1 && array_type_bracket_index + 2 == type.length,
             };
           columns.push(col);
         });
@@ -2154,12 +2204,12 @@ define('tools.querytool', [
         }
       },
 
-      resetQueryHistoryObject: function (history) {
+      resetQueryHistoryObject: function(history) {
         history.total_time = '-';
       },
 
       // This function is used to raise appropriate message.
-      update_msg_history: function (status, msg, clear_grid) {
+      update_msg_history: function(status, msg, clear_grid) {
         var self = this;
         if (clear_grid === undefined)
           clear_grid = true;
@@ -2182,13 +2232,13 @@ define('tools.querytool', [
         }
 
         // Scroll automatically when msgs appends to element
-        setTimeout(function () {
-          $(".sql-editor-message").scrollTop($(".sql-editor-message")[0].scrollHeight);
-          ;
+        setTimeout(function() {
+          $('.sql-editor-message').scrollTop($('.sql-editor-message')[0].scrollHeight);
+
         }, 10);
 
         if (status != 'Busy') {
-          $("#btn-flash").prop('disabled', false);
+          $('#btn-flash').prop('disabled', false);
           self.trigger('pgadmin-sqleditor:loading-icon:hide');
           self.gridView.history_collection.add({
             'status': status,
@@ -2202,9 +2252,7 @@ define('tools.querytool', [
       },
 
       // This function will return the total query execution Time.
-      get_query_run_time: function (start_time, end_time) {
-        var self = this;
-
+      get_query_run_time: function(start_time, end_time) {
         // Calculate the difference in milliseconds
         var difference_ms, miliseconds;
         difference_ms = miliseconds = end_time.getTime() - start_time.getTime();
@@ -2218,8 +2266,7 @@ define('tools.querytool', [
           return minutes + ' min';
         else if (seconds > 0) {
           return seconds + ' secs';
-        }
-        else
+        } else
           return miliseconds + ' msec';
       },
 
@@ -2227,23 +2274,23 @@ define('tools.querytool', [
        * is editable or not depending on primary keys
        * and staged_rows flag
        */
-      is_editable: function (obj) {
+      is_editable: function(obj) {
         var self = this;
         if (obj instanceof Backbone.Collection)
           return false;
         return (self.get('can_edit'));
       },
 
-      rows_to_delete: function (data) {
+      rows_to_delete: function(data) {
         var self = this,
           tmp_keys = self.primary_keys;
 
         // re-calculate rows with no primary keys
         self.temp_new_rows = [];
-        data.forEach(function (d, idx) {
+        data.forEach(function(d, idx) {
           var p_keys_list = _.pick(d, tmp_keys),
             is_primary_key = Object.keys(p_keys_list).length ?
-              p_keys_list[0] : undefined;
+            p_keys_list[0] : undefined;
 
           if (!is_primary_key) {
             self.temp_new_rows.push(idx);
@@ -2253,15 +2300,15 @@ define('tools.querytool', [
       },
 
       // This function will delete selected row.
-      _delete: function () {
-        var self = this, deleted_keys = [],
-          dgrid = document.getElementById("datagrid"),
+      _delete: function() {
+        var self = this,
+          deleted_keys = [],
           is_added = _.size(self.data_store.added),
           is_updated = _.size(self.data_store.updated);
 
         // Remove newly added rows from staged rows as we don't want to send them on server
         if (is_added) {
-          _.each(self.data_store.added, function (val, key) {
+          _.each(self.data_store.added, function(val, key) {
             if (key in self.data_store.staged_rows) {
               // Remove the row from data store so that we do not send it on server
               deleted_keys.push(key);
@@ -2275,9 +2322,7 @@ define('tools.querytool', [
         // then just re-render the grid
         if (_.size(self.data_store.staged_rows) == 0) {
           var grid = self.slickgrid,
-            dataView = grid.getData(),
-            data = dataView.getItems(),
-            idx = 0;
+            dataView = grid.getData();
 
           grid.resetActiveCell();
 
@@ -2291,50 +2336,52 @@ define('tools.querytool', [
           grid.setSelectedRows([]);
           grid.invalidate();
 
-              // Nothing to copy or delete here
-              $("#btn-delete-row").prop('disabled', true);
-              $("#btn-copy-row").prop('disabled', true);
-              if(_.size(self.data_store.added) || is_updated) {
-                // Do not disable save button if there are
-                // any other changes present in grid data
-                $("#btn-save").prop('disabled', false);
-              } else {
-                $("#btn-save").prop('disabled', true);
-              }
-              alertify.success(gettext("Row(s) deleted."));
+          // Nothing to copy or delete here
+          $('#btn-delete-row').prop('disabled', true);
+          $('#btn-copy-row').prop('disabled', true);
+          if (_.size(self.data_store.added) || is_updated) {
+            // Do not disable save button if there are
+            // any other changes present in grid data
+            $('#btn-save').prop('disabled', false);
           } else {
-            // There are other data to needs to be updated on server
-            if(is_updated) {
-              alertify.alert(gettext("Operation failed"),
-                    gettext("There are unsaved changes in the grid. Please save them first to avoid data inconsistencies.")
-                  );
-              return;
-            }
-            alertify.confirm(gettext("Delete Row(s)"),
-                  gettext("Are you sure you wish to delete selected row(s)?"),
-              function() {
-                $("#btn-delete-row").prop('disabled', true);
-                $("#btn-copy-row").prop('disabled', true);
-                // Change the state
-                self.data_store.deleted = self.data_store.staged_rows;
-                self.data_store.staged_rows = {};
-                // Save the changes on server
-                self._save();
-              },
-              function() {
-                // Do nothing as user canceled the operation.
-              }
-            ).set('labels', {ok: gettext("Yes"), cancel:gettext("No")});
+            $('#btn-save').prop('disabled', true);
           }
-        },
+          alertify.success(gettext('Row(s) deleted.'));
+        } else {
+          // There are other data to needs to be updated on server
+          if (is_updated) {
+            alertify.alert(gettext('Operation failed'),
+              gettext('There are unsaved changes in the grid. Please save them first to avoid data inconsistencies.')
+            );
+            return;
+          }
+          alertify.confirm(gettext('Delete Row(s)'),
+            gettext('Are you sure you wish to delete selected row(s)?'),
+            function() {
+              $('#btn-delete-row').prop('disabled', true);
+              $('#btn-copy-row').prop('disabled', true);
+              // Change the state
+              self.data_store.deleted = self.data_store.staged_rows;
+              self.data_store.staged_rows = {};
+              // Save the changes on server
+              self._save();
+            },
+            function() {
+              // Do nothing as user canceled the operation.
+            }
+          ).set('labels', {
+            ok: gettext('Yes'),
+            cancel: gettext('No'),
+          });
+        }
+      },
 
       /* This function will fetch the list of changed models and make
        * the ajax call to save the data into the database server.
        * and will open save file dialog conditionally.
        */
-      _save: function (view, controller, save_as) {
+      _save: function(view, controller, save_as) {
         var self = this,
-          data = [],
           save_data = true;
 
         // Open save file dialog if query tool
@@ -2342,37 +2389,35 @@ define('tools.querytool', [
           var current_file = self.gridView.current_file;
           if (!_.isUndefined(current_file) && !save_as) {
             self._save_file_handler(current_file);
-          }
-          else {
+          } else {
             // provide custom option to save file dialog
             var params = {
-              'supported_types': ["*", "sql"],
+              'supported_types': ['*', 'sql'],
               'dialog_type': 'create_file',
               'dialog_title': 'Save File',
-              'btn_primary': 'Save'
-            }
+              'btn_primary': 'Save',
+            };
             pgAdmin.FileManager.init();
             pgAdmin.FileManager.show_dialog(params);
           }
           return;
         }
-        $("#btn-save").prop('disabled', true);
-        $("#btn-file-menu-dropdown").prop('disabled', true);
+        $('#btn-save').prop('disabled', true);
+        $('#btn-file-menu-dropdown').prop('disabled', true);
 
         var is_added = _.size(self.data_store.added),
           is_updated = _.size(self.data_store.updated),
-          is_deleted = _.size(self.data_store.deleted),
-          is_primary_error = false;
+          is_deleted = _.size(self.data_store.deleted);
 
         if (!is_added && !is_updated && !is_deleted) {
-          return;  // Nothing to save here
+          return; // Nothing to save here
         }
 
         if (save_data) {
 
           self.trigger(
             'pgadmin-sqleditor:loading-icon:show',
-            gettext("Saving the updated data...")
+            gettext('Saving the updated data...')
           );
 
           // Add the columns to the data so the server can remap the data
@@ -2381,22 +2426,24 @@ define('tools.querytool', [
 
           // Make ajax call to save the data
           $.ajax({
-            url: url_for('sqleditor.save', {'trans_id': self.transId}),
+            url: url_for('sqleditor.save', {
+              'trans_id': self.transId,
+            }),
             method: 'POST',
-            contentType: "application/json",
+            contentType: 'application/json',
             data: JSON.stringify(req_data),
-            success: function (res) {
+            success: function(res) {
               var grid = self.slickgrid,
                 dataView = grid.getData(),
                 data_length = dataView.getLength(),
                 data = [];
 
               if (res.data.status) {
-                if(is_added) {
+                if (is_added) {
                   // Update the rows in a grid after addition
                   dataView.beginUpdate();
-                  _.each(res.data.query_result, function (r) {
-                    if(!_.isNull(r.row_added)) {
+                  _.each(res.data.query_result, function(r) {
+                    if (!_.isNull(r.row_added)) {
                       // Fetch temp_id returned by server after addition
                       var row_id = Object.keys(r.row_added)[0];
                       _.each(req_data.added_index, function(v, k) {
@@ -2405,13 +2452,13 @@ define('tools.querytool', [
                           var item = grid.getDataItem(k);
                           _.extend(item, r.row_added[row_id]);
                         }
-                      })
+                      });
                     }
                   });
                   dataView.endUpdate();
                 }
                 // Remove flag is_row_copied from copied rows
-                _.each(data, function (row, idx) {
+                _.each(data, function(row) {
                   if (row.is_row_copied) {
                     delete row.is_row_copied;
                   }
@@ -2450,7 +2497,7 @@ define('tools.querytool', [
                   'updated': {},
                   'deleted': {},
                   'added_index': {},
-                  'updated_index': {}
+                  'updated_index': {},
                 };
 
                 // Reset old primary key data now
@@ -2459,35 +2506,35 @@ define('tools.querytool', [
                 // Clear msgs after successful save
                 $('.sql-editor-message').html('');
 
-                alertify.success(gettext("Data saved successfully."));
+                alertify.success(gettext('Data saved successfully.'));
               } else {
                 // Something went wrong while saving data on the db server
-                $("#btn-flash").prop('disabled', false);
+                $('#btn-flash').prop('disabled', false);
                 $('.sql-editor-message').text(res.data.result);
-                var err_msg = S(gettext("%s.")).sprintf(res.data.result).value();
+                var err_msg = S(gettext('%s.')).sprintf(res.data.result).value();
                 alertify.error(err_msg, 20);
                 grid.setSelectedRows([]);
                 // To highlight the row at fault
-                if(_.has(res.data, '_rowid') &&
-                  (!_.isUndefined(res.data._rowid)|| !_.isNull(res.data._rowid))) {
-                    var _row_index = self._find_rowindex(res.data._rowid);
-                    if(_row_index in self.data_store.added_index) {
-                      // Remove new row index from temp_list if save operation
-                      // fails
-                      var index = self.handler.temp_new_rows.indexOf(res.data._rowid);
-                      if (index > -1) {
-                        self.handler.temp_new_rows.splice(index, 1);
-                      }
-                      self.data_store.added[self.data_store.added_index[_row_index]].err = true
-                    } else if (_row_index in self.data_store.updated_index) {
-                      self.data_store.updated[self.data_store.updated_index[_row_index]].err = true
+                if (_.has(res.data, '_rowid') &&
+                  (!_.isUndefined(res.data._rowid) || !_.isNull(res.data._rowid))) {
+                  var _row_index = self._find_rowindex(res.data._rowid);
+                  if (_row_index in self.data_store.added_index) {
+                    // Remove new row index from temp_list if save operation
+                    // fails
+                    var index = self.handler.temp_new_rows.indexOf(res.data._rowid);
+                    if (index > -1) {
+                      self.handler.temp_new_rows.splice(index, 1);
                     }
+                    self.data_store.added[self.data_store.added_index[_row_index]].err = true;
+                  } else if (_row_index in self.data_store.updated_index) {
+                    self.data_store.updated[self.data_store.updated_index[_row_index]].err = true;
                   }
+                }
                 grid.gotoCell(_row_index, 1);
               }
 
               // Update the sql results in history tab
-              _.each(res.data.query_result, function (r) {
+              _.each(res.data.query_result, function(r) {
                 self.gridView.history_collection.add({
                   'status': r.status,
                   'start_time': self.query_start_time,
@@ -2499,18 +2546,18 @@ define('tools.querytool', [
               });
               self.trigger('pgadmin-sqleditor:loading-icon:hide');
 
-                grid.invalidate();
-                if (self.close_on_save) {
-                  self.close();
-                }
-              },
-              error: function(e) {
-                if (e.readyState == 0) {
-                  self.update_msg_history(false,
-                    gettext("Not connected to the server or the connection to the server has been closed.")
-                  );
-                  return;
-                }
+              grid.invalidate();
+              if (self.close_on_save) {
+                self.close();
+              }
+            },
+            error: function(e) {
+              if (e.readyState == 0) {
+                self.update_msg_history(false,
+                  gettext('Not connected to the server or the connection to the server has been closed.')
+                );
+                return;
+              }
 
               var msg = e.responseText;
               if (e.responseJSON != undefined &&
@@ -2518,13 +2565,13 @@ define('tools.querytool', [
                 msg = e.responseJSON.errormsg;
 
               self.update_msg_history(false, msg);
-            }
+            },
           });
         }
       },
 
       // Find index of row at fault from grid data
-      _find_rowindex: function (rowid) {
+      _find_rowindex: function(rowid) {
         var self = this,
           grid = self.slickgrid,
           dataView = grid.getData(),
@@ -2537,7 +2584,7 @@ define('tools.querytool', [
         if (_.isObject(rowid)) {
           _rowid = rowid;
         } else if (_.isString(rowid)) { // Insert operation
-          var rowid = {};
+          rowid = {};
           rowid[self.client_primary_key] = rowid;
           _rowid = rowid;
         } else {
@@ -2545,10 +2592,10 @@ define('tools.querytool', [
           return _idx;
         }
 
-        _.find(data, function (d) {
+        _.find(data, function(d) {
           // search for unique id in row data if found than its the row
           // which error out on server side
-          var tmp = [];  //_.findWhere needs array of object to work
+          var tmp = []; //_.findWhere needs array of object to work
           tmp.push(d);
           if (_.findWhere(tmp, _rowid)) {
             _idx = count;
@@ -2563,18 +2610,18 @@ define('tools.querytool', [
       },
 
       // Save as
-      _save_as: function () {
+      _save_as: function() {
         return this._save(true);
       },
 
       // Set panel title.
-      setTitle: function (title) {
+      setTitle: function(title) {
         var self = this;
 
         if (self.is_new_browser_tab) {
           window.document.title = title;
         } else {
-          _.each(window.top.pgAdmin.Browser.docker.findPanels('frm_datagrid'), function (p) {
+          _.each(window.top.pgAdmin.Browser.docker.findPanels('frm_datagrid'), function(p) {
             if (p.isVisible()) {
               p.title(decodeURIComponent(title));
             }
@@ -2583,23 +2630,26 @@ define('tools.querytool', [
       },
 
       // load select file dialog
-      _load_file: function () {
+      _load_file: function() {
         var self = this;
 
         /* If is_query_changed flag is set to false then no need to
          * confirm with the user for unsaved changes.
          */
         if (self.is_query_changed) {
-          alertify.confirm(gettext("Unsaved changes"),
-            gettext("Are you sure you wish to discard the current changes?"),
-            function () {
+          alertify.confirm(gettext('Unsaved changes'),
+            gettext('Are you sure you wish to discard the current changes?'),
+            function() {
               // User do not want to save, just continue
               self._open_select_file_manager();
             },
-            function () {
+            function() {
               return true;
             }
-          ).set('labels', {ok: 'Yes', cancel: 'No'});
+          ).set('labels', {
+            ok: 'Yes',
+            cancel: 'No',
+          });
         } else {
           self._open_select_file_manager();
         }
@@ -2607,25 +2657,25 @@ define('tools.querytool', [
       },
 
       // Open FileManager
-      _open_select_file_manager: function () {
+      _open_select_file_manager: function() {
         var params = {
-          'supported_types': ["sql"], // file types allowed
-          'dialog_type': 'select_file' // open select file dialog
-        }
+          'supported_types': ['sql'], // file types allowed
+          'dialog_type': 'select_file', // open select file dialog
+        };
         pgAdmin.FileManager.init();
         pgAdmin.FileManager.show_dialog(params);
       },
 
       // read file data and return as response
-      _select_file_handler: function (e) {
+      _select_file_handler: function(e) {
         var self = this,
           data = {
-            'file_name': decodeURI(e)
+            'file_name': decodeURI(e),
           };
 
         self.trigger(
           'pgadmin-sqleditor:loading-icon:show',
-          gettext("Loading the file...")
+          gettext('Loading the file...')
         );
         // set cursor to progress before file load
         var $busy_icon_div = $('.sql-editor-busy-fetching');
@@ -2635,9 +2685,9 @@ define('tools.querytool', [
         $.ajax({
           url: url_for('sqleditor.load_file'),
           method: 'POST',
-          contentType: "application/json",
+          contentType: 'application/json',
           data: JSON.stringify(data),
-          success: function (res) {
+          success: function(res) {
             self.gridView.query_tool_obj.setValue(res);
             self.gridView.current_file = e;
             self.setTitle(self.gridView.current_file.split('\\').pop().split('/').pop());
@@ -2646,72 +2696,72 @@ define('tools.querytool', [
             $busy_icon_div.removeClass('show_progress');
 
             // disable save button on file save
-            $("#btn-save").prop('disabled', true);
-            $("#btn-file-menu-save").css('display', 'none');
+            $('#btn-save').prop('disabled', true);
+            $('#btn-file-menu-save').css('display', 'none');
 
-              // Update the flag as new content is just loaded.
-              self.is_query_changed = false;
-            },
-            error: function(e) {
-              var errmsg = $.parseJSON(e.responseText).errormsg;
-              alertify.error(errmsg);
-              self.trigger('pgadmin-sqleditor:loading-icon:hide');
-              // hide cursor
-              $busy_icon_div.removeClass('show_progress');
-            }
-          });
-        },
+            // Update the flag as new content is just loaded.
+            self.is_query_changed = false;
+          },
+          error: function(e) {
+            var errmsg = $.parseJSON(e.responseText).errormsg;
+            alertify.error(errmsg);
+            self.trigger('pgadmin-sqleditor:loading-icon:hide');
+            // hide cursor
+            $busy_icon_div.removeClass('show_progress');
+          },
+        });
+      },
 
       // read data from codemirror and write to file
-      _save_file_handler: function (e) {
+      _save_file_handler: function(e) {
         var self = this,
           data = {
             'file_name': decodeURI(e),
-            'file_content': self.gridView.query_tool_obj.getValue()
+            'file_content': self.gridView.query_tool_obj.getValue(),
           };
         self.trigger(
           'pgadmin-sqleditor:loading-icon:show',
-          gettext("Saving the queries in the file...")
+          gettext('Saving the queries in the file...')
         );
 
-          // Make ajax call to save the data to file
-          $.ajax({
-            url: url_for('sqleditor.save_file'),
-            method: 'POST',
-            contentType: "application/json",
-            data: JSON.stringify(data),
-            success: function(res) {
-              if (res.data.status) {
-                alertify.success(gettext("File saved successfully."));
-                self.gridView.current_file = e;
-                self.setTitle(self.gridView.current_file.replace(/^.*[\\\/]/g, ''));
-                // disable save button on file save
-                $("#btn-save").prop('disabled', true);
-                $("#btn-file-menu-save").css('display', 'none');
+        // Make ajax call to save the data to file
+        $.ajax({
+          url: url_for('sqleditor.save_file'),
+          method: 'POST',
+          contentType: 'application/json',
+          data: JSON.stringify(data),
+          success: function(res) {
+            if (res.data.status) {
+              alertify.success(gettext('File saved successfully.'));
+              self.gridView.current_file = e;
+              self.setTitle(self.gridView.current_file.replace(/^.*[\\\/]/g, ''));
+              // disable save button on file save
+              $('#btn-save').prop('disabled', true);
+              $('#btn-file-menu-save').css('display', 'none');
 
               // Update the flag as query is already saved.
               self.is_query_changed = false;
             }
             self.trigger('pgadmin-sqleditor:loading-icon:hide');
             if (self.close_on_save) {
-              self.close()
+              self.close();
             }
           },
-          error: function (e) {
+          error: function(e) {
             self.trigger('pgadmin-sqleditor:loading-icon:hide');
 
-              var errmsg = $.parseJSON(e.responseText).errormsg;
-              setTimeout(
-                function() {
-                  alertify.error(errmsg);
-                }, 10
-              );
-            },
-          });
-        },
+            var errmsg = $.parseJSON(e.responseText).errormsg;
+            setTimeout(
+              function() {
+                alertify.error(errmsg);
+              }, 10
+            );
+          },
+        });
+      },
 
       // codemirror text change event
-      _on_query_change: function (query_tool_obj) {
+      _on_query_change: function() {
         var self = this;
 
         if (!self.is_query_changed) {
@@ -2719,16 +2769,14 @@ define('tools.querytool', [
           self.is_query_changed = true;
 
           if (self.gridView.current_file) {
-            var title = self.gridView.current_file.replace(/^.*[\\\/]/g, '') + ' *'
+            var title = self.gridView.current_file.replace(/^.*[\\\/]/g, '') + ' *';
             self.setTitle(title);
           } else {
-            var title = '';
-
             if (self.is_new_browser_tab) {
               title = window.document.title + ' *';
             } else {
               // Find the title of the visible panel
-              _.each(window.top.pgAdmin.Browser.docker.findPanels('frm_datagrid'), function (p) {
+              _.each(window.top.pgAdmin.Browser.docker.findPanels('frm_datagrid'), function(p) {
                 if (p.isVisible()) {
                   self.gridView.panel_title = p._title;
                 }
@@ -2739,50 +2787,48 @@ define('tools.querytool', [
             self.setTitle(title);
           }
 
-          $("#btn-save").prop('disabled', false);
-          $("#btn-file-menu-save").css('display', 'block');
-          $("#btn-file-menu-dropdown").prop('disabled', false);
+          $('#btn-save').prop('disabled', false);
+          $('#btn-file-menu-save').css('display', 'block');
+          $('#btn-file-menu-dropdown').prop('disabled', false);
         }
       },
 
       // This function will set the required flag for polling response data
-      _init_polling_flags: function () {
+      _init_polling_flags: function() {
         var self = this;
 
         // To get a timeout for polling fallback timer in seconds in
         // regards to elapsed time
-        self.POLL_FALLBACK_TIME = function () {
+        self.POLL_FALLBACK_TIME = function() {
           var seconds = parseInt((Date.now() - self.query_start_time.getTime()) / 1000);
           // calculate & return fall back polling timeout
           if (seconds >= 10 && seconds < 30) {
             return 500;
-          }
-          else if (seconds >= 30 && seconds < 60) {
+          } else if (seconds >= 30 && seconds < 60) {
             return 1000;
-          }
-          else if (seconds >= 60 && seconds < 90) {
+          } else if (seconds >= 60 && seconds < 90) {
             return 2000;
-          }
-          else if (seconds >= 90) {
+          } else if (seconds >= 90) {
             return 5000;
-          }
-          else
+          } else
             return 1;
-        }
+        };
       },
 
       // This function will show the filter in the text area.
-      _show_filter: function () {
+      _show_filter: function() {
         var self = this;
 
         self.trigger(
           'pgadmin-sqleditor:loading-icon:show',
-          gettext("Loading the existing filter options...")
+          gettext('Loading the existing filter options...')
         );
         $.ajax({
-          url: url_for('sqleditor.get_filter', {'trans_id': self.transId}),
+          url: url_for('sqleditor.get_filter', {
+            'trans_id': self.transId,
+          }),
           method: 'GET',
-          success: function (res) {
+          success: function(res) {
             self.trigger('pgadmin-sqleditor:loading-icon:hide');
             if (res.data.status) {
               $('#filter').removeClass('hidden');
@@ -2797,19 +2843,19 @@ define('tools.querytool', [
               self.gridView.filter_obj.focus();
             } else {
               setTimeout(
-                function () {
+                function() {
                   alertify.alert(gettext('Get Filter Error'), res.data.result);
                 }, 10
               );
             }
           },
-          error: function (e) {
+          error: function(e) {
             self.trigger('pgadmin-sqleditor:loading-icon:hide');
 
             var msg;
             if (e.readyState == 0) {
               msg =
-                gettext("Not connected to the server or the connection to the server has been closed.")
+                gettext('Not connected to the server or the connection to the server has been closed.');
             } else {
               msg = e.responseText;
               if (e.responseJSON != undefined &&
@@ -2817,18 +2863,19 @@ define('tools.querytool', [
                 msg = e.responseJSON.errormsg;
             }
             setTimeout(
-              function () {
+              function() {
                 alertify.alert(gettext('Get Filter Error'), msg);
               }, 10
             );
-          }
+          },
         });
       },
 
       // This function will include the filter by selection.
-      _include_filter: function () {
+      _include_filter: function() {
         var self = this,
-          data = {}, grid, active_column, column_info, _values;
+          data = {},
+          grid, active_column, column_info, _values;
 
         grid = self.slickgrid;
         active_column = grid.getActiveCell();
@@ -2837,10 +2884,10 @@ define('tools.querytool', [
         if (_.isNull(active_column) || _.isUndefined(active_column))
           return;
 
-        column_info = grid.getColumns()[active_column.cell]
+        column_info = grid.getColumns()[active_column.cell];
 
         // Fetch current row data from grid
-        _values = grid.getDataItem(active_column.row, active_column.cell)
+        _values = grid.getDataItem(active_column.row, active_column.cell);
         if (_.isNull(_values) || _.isUndefined(_values))
           return;
 
@@ -2849,36 +2896,37 @@ define('tools.querytool', [
 
         self.trigger(
           'pgadmin-sqleditor:loading-icon:show',
-          gettext("Applying the new filter...")
+          gettext('Applying the new filter...')
         );
 
         // Make ajax call to include the filter by selection
         $.ajax({
-          url: url_for('sqleditor.inclusive_filter', {'trans_id': self.transId}),
+          url: url_for('sqleditor.inclusive_filter', {
+            'trans_id': self.transId,
+          }),
           method: 'POST',
-          contentType: "application/json",
+          contentType: 'application/json',
           data: JSON.stringify(data),
-          success: function (res) {
+          success: function(res) {
             self.trigger('pgadmin-sqleditor:loading-icon:hide');
             setTimeout(
-              function () {
+              function() {
                 if (res.data.status) {
                   // Refresh the sql grid
                   queryToolActions.executeQuery(self);
-                }
-                else {
+                } else {
                   alertify.alert(gettext('Filter By Selection Error'), res.data.result);
                 }
               }
             );
           },
-          error: function (e) {
+          error: function(e) {
             self.trigger('pgadmin-sqleditor:loading-icon:hide');
             setTimeout(
-              function () {
+              function() {
                 if (e.readyState == 0) {
                   alertify.alert(gettext('Filter By Selection Error'),
-                    gettext("Not connected to the server or the connection to the server has been closed.")
+                    gettext('Not connected to the server or the connection to the server has been closed.')
                   );
                   return;
                 }
@@ -2891,14 +2939,15 @@ define('tools.querytool', [
                 alertify.alert(gettext('Filter By Selection Error'), msg);
               }, 10
             );
-          }
+          },
         });
       },
 
       // This function will exclude the filter by selection.
-      _exclude_filter: function () {
+      _exclude_filter: function() {
         var self = this,
-          data = {}, grid, active_column, column_info, _values;
+          data = {},
+          grid, active_column, column_info, _values;
 
         grid = self.slickgrid;
         active_column = grid.getActiveCell();
@@ -2907,10 +2956,10 @@ define('tools.querytool', [
         if (_.isNull(active_column) || _.isUndefined(active_column))
           return;
 
-        column_info = grid.getColumns()[active_column.cell]
+        column_info = grid.getColumns()[active_column.cell];
 
         // Fetch current row data from grid
-        _values = grid.getDataItem(active_column.row, active_column.cell)
+        _values = grid.getDataItem(active_column.row, active_column.cell);
         if (_.isNull(_values) || _.isUndefined(_values))
           return;
 
@@ -2919,37 +2968,38 @@ define('tools.querytool', [
 
         self.trigger(
           'pgadmin-sqleditor:loading-icon:show',
-          gettext("Applying the new filter...")
+          gettext('Applying the new filter...')
         );
 
         // Make ajax call to exclude the filter by selection.
         $.ajax({
-          url: url_for('sqleditor.exclusive_filter', {'trans_id': self.transId}),
+          url: url_for('sqleditor.exclusive_filter', {
+            'trans_id': self.transId,
+          }),
           method: 'POST',
-          contentType: "application/json",
+          contentType: 'application/json',
           data: JSON.stringify(data),
-          success: function (res) {
+          success: function(res) {
             self.trigger('pgadmin-sqleditor:loading-icon:hide');
             setTimeout(
-              function () {
+              function() {
                 if (res.data.status) {
                   // Refresh the sql grid
                   queryToolActions.executeQuery(self);
-                }
-                else {
+                } else {
                   alertify.alert(gettext('Filter Exclude Selection Error'), res.data.result);
                 }
               }, 10
             );
           },
-          error: function (e) {
+          error: function(e) {
             self.trigger('pgadmin-sqleditor:loading-icon:hide');
 
             setTimeout(
-              function () {
+              function() {
                 if (e.readyState == 0) {
                   alertify.alert(gettext('Filter Exclude Selection Error'),
-                    gettext("Not connected to the server or the connection to the server has been closed.")
+                    gettext('Not connected to the server or the connection to the server has been closed.')
                   );
                   return;
                 }
@@ -2962,44 +3012,45 @@ define('tools.querytool', [
                 alertify.alert(gettext('Filter Exclude Selection Error'), msg);
               }, 10
             );
-          }
+          },
         });
       },
 
       // This function will remove the filter.
-      _remove_filter: function () {
+      _remove_filter: function() {
         var self = this;
 
         self.trigger(
           'pgadmin-sqleditor:loading-icon:show',
-          gettext("Removing the filter...")
+          gettext('Removing the filter...')
         );
 
         // Make ajax call to exclude the filter by selection.
         $.ajax({
-          url: url_for('sqleditor.remove_filter', {'trans_id': self.transId}),
+          url: url_for('sqleditor.remove_filter', {
+            'trans_id': self.transId,
+          }),
           method: 'POST',
-          success: function (res) {
+          success: function(res) {
             self.trigger('pgadmin-sqleditor:loading-icon:hide');
             setTimeout(
-              function () {
+              function() {
                 if (res.data.status) {
                   // Refresh the sql grid
                   queryToolActions.executeQuery(self);
-                }
-                else {
+                } else {
                   alertify.alert(gettext('Remove Filter Error'), res.data.result);
                 }
               }
             );
           },
-          error: function (e) {
+          error: function(e) {
             self.trigger('pgadmin-sqleditor:loading-icon:hide');
             setTimeout(
-              function () {
+              function() {
                 if (e.readyState == 0) {
                   alertify.alert(gettext('Remove Filter Error'),
-                    gettext("Not connected to the server or the connection to the server has been closed.")
+                    gettext('Not connected to the server or the connection to the server has been closed.')
                   );
                   return;
                 }
@@ -3012,49 +3063,50 @@ define('tools.querytool', [
                 alertify.alert(gettext('Remove Filter Error'), msg);
               }
             );
-          }
+          },
         });
       },
 
       // This function will apply the filter.
-      _apply_filter: function () {
+      _apply_filter: function() {
         var self = this,
           sql = self.gridView.filter_obj.getValue();
 
         self.trigger(
           'pgadmin-sqleditor:loading-icon:show',
-          gettext("Applying the filter...")
+          gettext('Applying the filter...')
         );
 
         // Make ajax call to include the filter by selection
         $.ajax({
-          url: url_for('sqleditor.apply_filter', {'trans_id': self.transId}),
+          url: url_for('sqleditor.apply_filter', {
+            'trans_id': self.transId,
+          }),
           method: 'POST',
-          contentType: "application/json",
+          contentType: 'application/json',
           data: JSON.stringify(sql),
-          success: function (res) {
+          success: function(res) {
             self.trigger('pgadmin-sqleditor:loading-icon:hide');
             setTimeout(
-              function () {
+              function() {
                 if (res.data.status) {
                   $('#filter').addClass('hidden');
                   $('#editor-panel').removeClass('sql-editor-busy-fetching');
                   // Refresh the sql grid
                   queryToolActions.executeQuery(self);
-                }
-                else {
+                } else {
                   alertify.alert(gettext('Apply Filter Error'), res.data.result);
                 }
               }, 10
             );
           },
-          error: function (e) {
+          error: function(e) {
             self.trigger('pgadmin-sqleditor:loading-icon:hide');
             setTimeout(
-              function () {
+              function() {
                 if (e.readyState == 0) {
                   alertify.alert(gettext('Apply Filter Error'),
-                    gettext("Not connected to the server or the connection to the server has been closed.")
+                    gettext('Not connected to the server or the connection to the server has been closed.')
                   );
                   return;
                 }
@@ -3067,7 +3119,7 @@ define('tools.querytool', [
                 alertify.alert(gettext('Apply Filter Error'), msg);
               }, 10
             );
-          }
+          },
         });
       },
 
@@ -3075,18 +3127,18 @@ define('tools.querytool', [
       _copy_row: copyData,
 
       // This function will paste the selected row.
-      _paste_row: function () {
-        var self = this, col_info = {},
+      _paste_row: function() {
+        var self = this,
           grid = self.slickgrid,
           dataView = grid.getData(),
           data = dataView.getItems(),
           count = dataView.getLength(),
           rows = grid.getSelectedRows().sort(
-            function (a, b) {
+            function(a, b) {
               return a - b;
             }
           ),
-          copied_rows = rows.map(function (rowIndex) {
+          copied_rows = rows.map(function(rowIndex) {
             return data[rowIndex];
           }),
           array_types = [];
@@ -3098,7 +3150,7 @@ define('tools.querytool', [
           }
         }
 
-        rows = rows.length == 0 ? self.last_copied_rows : rows
+        rows = rows.length == 0 ? self.last_copied_rows : rows;
 
         self.last_copied_rows = rows;
 
@@ -3106,14 +3158,12 @@ define('tools.querytool', [
         if (copied_rows.length > 0) {
           // Enable save button so that user can
           // save newly pasted rows on server
-          $("#btn-save").prop('disabled', false);
+          $('#btn-save').prop('disabled', false);
 
-          var arr_to_object = function (arr) {
-            var obj = {},
-              count = typeof(arr) == 'object' ?
-                Object.keys(arr).length : arr.length
+          var arr_to_object = function(arr) {
+            var obj = {};
 
-            _.each(arr, function (val, i) {
+            _.each(arr, function(val, i) {
               if (arr[i] !== undefined) {
                 // Do not stringify array types.
                 if (_.isObject(arr[i]) && array_types.indexOf(i) == -1) {
@@ -3135,14 +3185,17 @@ define('tools.querytool', [
           // Reset selection
 
           dataView.beginUpdate();
-          _.each(copied_rows, function (row) {
+          _.each(copied_rows, function(row) {
             var new_row = arr_to_object(row),
               _key = (self.gridView.client_primary_key_counter++).toString();
             new_row.is_row_copied = true;
             self.temp_new_rows.push(count);
             new_row[self.client_primary_key] = _key;
             dataView.addItem(new_row);
-            self.data_store.added[_key] = {'err': false, 'data': new_row};
+            self.data_store.added[_key] = {
+              'err': false,
+              'data': new_row,
+            };
             self.data_store.added_index[count] = _key;
             count++;
           });
@@ -3155,40 +3208,41 @@ define('tools.querytool', [
       },
 
       // This function will set the limit for SQL query
-      _set_limit: function () {
+      _set_limit: function() {
         var self = this,
-          limit = parseInt($(".limit").val());
+          limit = parseInt($('.limit').val());
 
         self.trigger(
           'pgadmin-sqleditor:loading-icon:show',
-          gettext("Setting the limit on the result...")
+          gettext('Setting the limit on the result...')
         );
         // Make ajax call to change the limit
         $.ajax({
-          url: url_for('sqleditor.set_limit', {'trans_id': self.transId}),
+          url: url_for('sqleditor.set_limit', {
+            'trans_id': self.transId,
+          }),
           method: 'POST',
-          contentType: "application/json",
+          contentType: 'application/json',
           data: JSON.stringify(limit),
-          success: function (res) {
+          success: function(res) {
             self.trigger('pgadmin-sqleditor:loading-icon:hide');
             setTimeout(
-              function () {
+              function() {
                 if (res.data.status) {
                   // Refresh the sql grid
                   queryToolActions.executeQuery(self);
-                }
-                else
+                } else
                   alertify.alert(gettext('Change limit Error'), res.data.result);
               }, 10
             );
           },
-          error: function (e) {
+          error: function(e) {
             self.trigger('pgadmin-sqleditor:loading-icon:hide');
             setTimeout(
-              function () {
+              function() {
                 if (e.readyState == 0) {
                   alertify.alert(gettext('Change limit Error'),
-                    gettext("Not connected to the server or the connection to the server has been closed.")
+                    gettext('Not connected to the server or the connection to the server has been closed.')
                   );
                   return;
                 }
@@ -3201,25 +3255,24 @@ define('tools.querytool', [
                 alertify.alert(gettext('Change limit Error'), msg);
               }, 10
             );
-          }
+          },
         });
       },
 
       // This function is used to enable/disable buttons
-      disable_tool_buttons: function (disabled) {
-        $("#btn-clear").prop('disabled', disabled);
-        $("#btn-query-dropdown").prop('disabled', disabled);
-        $("#btn-edit-dropdown").prop('disabled', disabled);
-        $("#btn-edit").prop('disabled', disabled);
+      disable_tool_buttons: function(disabled) {
+        $('#btn-clear').prop('disabled', disabled);
+        $('#btn-query-dropdown').prop('disabled', disabled);
+        $('#btn-edit-dropdown').prop('disabled', disabled);
+        $('#btn-edit').prop('disabled', disabled);
         $('#btn-load-file').prop('disabled', disabled);
       },
 
       // This function will fetch the sql query from the text box
       // and execute the query.
-      execute: function (explain_prefix) {
+      execute: function(explain_prefix) {
         var self = this,
-          sql = '',
-          history_msg = '';
+          sql = '';
 
         self.has_more_rows = false;
         self.fetching_rows = false;
@@ -3238,13 +3291,13 @@ define('tools.querytool', [
 
         self.trigger(
           'pgadmin-sqleditor:loading-icon:show',
-          gettext("Initializing query execution...")
+          gettext('Initializing query execution...')
         );
 
-        $("#btn-flash").prop('disabled', true);
+        $('#btn-flash').prop('disabled', true);
 
         if (explain_prefix != undefined &&
-          !S.startsWith(sql.trim().toUpperCase(), "EXPLAIN")) {
+          !S.startsWith(sql.trim().toUpperCase(), 'EXPLAIN')) {
           sql = explain_prefix + ' ' + sql;
         }
 
@@ -3253,14 +3306,16 @@ define('tools.querytool', [
         self.rows_affected = 0;
         self._init_polling_flags();
         self.disable_tool_buttons(true);
-        $("#btn-cancel-query").prop('disabled', false);
+        $('#btn-cancel-query').prop('disabled', false);
 
         $.ajax({
-          url: url_for('sqleditor.query_tool_start', {'trans_id': self.transId}),
+          url: url_for('sqleditor.query_tool_start', {
+            'trans_id': self.transId,
+          }),
           method: 'POST',
-          contentType: "application/json",
+          contentType: 'application/json',
           data: JSON.stringify(sql),
-          success: function (res) {
+          success: function(res) {
             // Remove marker
             if (self.gridView.marker) {
               self.gridView.marker.clear();
@@ -3274,7 +3329,7 @@ define('tools.querytool', [
             if (res.data.status) {
               self.trigger(
                 'pgadmin-sqleditor:loading-icon:message',
-                gettext("Waiting for the query execution to complete...")
+                gettext('Waiting for the query execution to complete...')
               );
 
               self.can_edit = res.data.can_edit;
@@ -3283,25 +3338,24 @@ define('tools.querytool', [
 
               // If status is True then poll the result.
               self._poll();
-            }
-            else {
+            } else {
               self.trigger('pgadmin-sqleditor:loading-icon:hide');
               self.disable_tool_buttons(false);
-              $("#btn-cancel-query").prop('disabled', true);
+              $('#btn-cancel-query').prop('disabled', true);
               self.update_msg_history(false, res.data.result);
 
               // Highlight the error in the sql panel
               self._highlight_error(res.data.result);
             }
           },
-          error: function (e) {
+          error: function(e) {
             self.trigger('pgadmin-sqleditor:loading-icon:hide');
             self.disable_tool_buttons(false);
-            $("#btn-cancel-query").prop('disabled', true);
+            $('#btn-cancel-query').prop('disabled', true);
 
             if (e.readyState == 0) {
               self.update_msg_history(false,
-                gettext("Not connected to the server or the connection to the server has been closed.")
+                gettext('Not connected to the server or the connection to the server has been closed.')
               );
               return;
             }
@@ -3312,14 +3366,14 @@ define('tools.querytool', [
               msg = e.responseJSON.errormsg;
 
             self.update_msg_history(false, msg);
-          }
+          },
         });
       },
 
       /* This function is used to highlight the error line and
        * underlining for the error word.
        */
-      _highlight_error: function (result) {
+      _highlight_error: function(result) {
         var self = this,
           error_line_no = 0,
           start_marker = 0,
@@ -3366,40 +3420,45 @@ define('tools.querytool', [
             end_marker = error_line.length;
 
           // Mark the error text
-          self.gridView.marker = self.gridView.query_tool_obj.markText(
-            {line: error_line_no, ch: start_marker},
-            {line: error_line_no, ch: end_marker},
-            {className: "sql-editor-mark"}
-          );
+          self.gridView.marker = self.gridView.query_tool_obj.markText({
+            line: error_line_no,
+            ch: start_marker,
+          }, {
+            line: error_line_no,
+            ch: end_marker,
+          }, {
+            className: 'sql-editor-mark',
+          });
 
           self.gridView.query_tool_obj.addLineClass(self.marked_line_no, 'wrap', 'CodeMirror-activeline-background');
         }
       },
 
       // This function will cancel the running query.
-      _cancel_query: function () {
+      _cancel_query: function() {
         var self = this;
 
-        $("#btn-cancel-query").prop('disabled', true);
+        $('#btn-cancel-query').prop('disabled', true);
         $.ajax({
-          url: url_for('sqleditor.cancel_transaction', {'trans_id': self.transId}),
+          url: url_for('sqleditor.cancel_transaction', {
+            'trans_id': self.transId,
+          }),
           method: 'POST',
-          contentType: "application/json",
-          success: function (res) {
+          contentType: 'application/json',
+          success: function(res) {
             if (res.data.status) {
               self.disable_tool_buttons(false);
-            }
-            else {
+            } else {
               self.disable_tool_buttons(false);
               alertify.alert(gettext('Cancel Query Error'), res.data.result);
             }
           },
-          error: function (e) {
+          error: function(e) {
             self.disable_tool_buttons(false);
 
             if (e.readyState == 0) {
               alertify.alert(gettext('Cancel Query Error'),
-                gettext("Not connected to the server or the connection to the server has been closed.")
+                gettext('Not connected to the server or the connection to the server has been closed.')
               );
               return;
             }
@@ -3410,21 +3469,26 @@ define('tools.querytool', [
               msg = e.responseJSON.errormsg;
 
             alertify.alert(gettext('Cancel Query Error'), msg);
-          }
+          },
         });
       },
 
       // Trigger query result download to csv.
-      trigger_csv_download: function (query, filename) {
+      trigger_csv_download: function(query, filename) {
         var self = this,
-          link = $(this.container).find("#download-csv"),
-          url = url_for('sqleditor.query_tool_download', {'trans_id': self.transId});
+          link = $(this.container).find('#download-csv'),
+          url = url_for('sqleditor.query_tool_download', {
+            'trans_id': self.transId,
+          });
 
-        url += "?" + $.param({query: query, filename: filename});
-        link.attr("src", url);
+        url += '?' + $.param({
+          query: query,
+          filename: filename,
+        });
+        link.attr('src', url);
       },
 
-      _auto_rollback: function () {
+      _auto_rollback: function() {
         var self = this,
           auto_rollback = true;
 
@@ -3437,18 +3501,20 @@ define('tools.querytool', [
 
         // Make ajax call to change the limit
         $.ajax({
-          url: url_for('sqleditor.auto_rollback', {'trans_id': self.transId}),
+          url: url_for('sqleditor.auto_rollback', {
+            'trans_id': self.transId,
+          }),
           method: 'POST',
-          contentType: "application/json",
+          contentType: 'application/json',
           data: JSON.stringify(auto_rollback),
-          success: function (res) {
+          success: function(res) {
             if (!res.data.status)
               alertify.alert(gettext('Auto Rollback Error'), res.data.result);
           },
-          error: function (e) {
+          error: function(e) {
             if (e.readyState == 0) {
               alertify.alert(gettext('Auto Rollback Error'),
-                gettext("Not connected to the server or the connection to the server has been closed.")
+                gettext('Not connected to the server or the connection to the server has been closed.')
               );
               return;
             }
@@ -3459,11 +3525,11 @@ define('tools.querytool', [
               msg = e.responseJSON.errormsg;
 
             alertify.alert(gettext('Auto Rollback Error'), msg);
-          }
+          },
         });
       },
 
-      _auto_commit: function () {
+      _auto_commit: function() {
         var self = this,
           auto_commit = true;
 
@@ -3476,18 +3542,20 @@ define('tools.querytool', [
 
         // Make ajax call to change the limit
         $.ajax({
-          url: url_for('sqleditor.auto_commit', {'trans_id': self.transId}),
+          url: url_for('sqleditor.auto_commit', {
+            'trans_id': self.transId,
+          }),
           method: 'POST',
-          contentType: "application/json",
+          contentType: 'application/json',
           data: JSON.stringify(auto_commit),
-          success: function (res) {
+          success: function(res) {
             if (!res.data.status)
               alertify.alert(gettext('Auto Commit Error'), res.data.result);
           },
-          error: function (e) {
+          error: function(e) {
             if (e.readyState == 0) {
               alertify.alert(gettext('Auto Commit Error'),
-                gettext("Not connected to the server or the connection to the server has been closed.")
+                gettext('Not connected to the server or the connection to the server has been closed.')
               );
               return;
             }
@@ -3498,175 +3566,181 @@ define('tools.querytool', [
               msg = e.responseJSON.errormsg;
 
             alertify.alert(gettext('Auto Commit Error'), msg);
-          }
+          },
         });
       },
 
       // This function will toggle "verbose" option in explain
-      _explain_verbose: function () {
+      _explain_verbose: function() {
         var self = this;
         if ($('.explain-verbose').hasClass('visibility-hidden') === true) {
           $('.explain-verbose').removeClass('visibility-hidden');
           self.explain_verbose = true;
-        }
-        else {
+        } else {
           $('.explain-verbose').addClass('visibility-hidden');
           self.explain_verbose = false;
         }
 
         // Set this option in preferences
         var data = {
-          'explain_verbose': self.explain_verbose
+          'explain_verbose': self.explain_verbose,
         };
 
         $.ajax({
-          url: url_for('sqleditor.query_tool_preferences', {'trans_id': self.transId}),
+          url: url_for('sqleditor.query_tool_preferences', {
+            'trans_id': self.transId,
+          }),
           method: 'PUT',
-          contentType: "application/json",
+          contentType: 'application/json',
           data: JSON.stringify(data),
-          success: function (res) {
+          success: function(res) {
             if (res.success == undefined || !res.success) {
               alertify.alert(gettext('Explain options error'),
-                gettext("Error occurred while setting verbose option in explain.")
+                gettext('Error occurred while setting verbose option in explain.')
               );
             }
           },
-          error: function (e) {
+          error: function() {
             alertify.alert(gettext('Explain options error'),
-              gettext("Error occurred while setting verbose option in explain.")
+              gettext('Error occurred while setting verbose option in explain.')
             );
             return;
-          }
+          },
         });
       },
 
       // This function will toggle "costs" option in explain
-      _explain_costs: function () {
+      _explain_costs: function() {
         var self = this;
         if ($('.explain-costs').hasClass('visibility-hidden') === true) {
           $('.explain-costs').removeClass('visibility-hidden');
           self.explain_costs = true;
-        }
-        else {
+        } else {
           $('.explain-costs').addClass('visibility-hidden');
           self.explain_costs = false;
         }
 
         // Set this option in preferences
         var data = {
-          'explain_costs': self.explain_costs
+          'explain_costs': self.explain_costs,
         };
 
         $.ajax({
-          url: url_for('sqleditor.query_tool_preferences', {'trans_id': self.transId}),
+          url: url_for('sqleditor.query_tool_preferences', {
+            'trans_id': self.transId,
+          }),
           method: 'PUT',
-          contentType: "application/json",
+          contentType: 'application/json',
           data: JSON.stringify(data),
-          success: function (res) {
+          success: function(res) {
             if (res.success == undefined || !res.success) {
               alertify.alert(gettext('Explain options error'),
-                gettext("Error occurred while setting costs option in explain.")
+                gettext('Error occurred while setting costs option in explain.')
               );
             }
           },
-          error: function (e) {
+          error: function() {
             alertify.alert(gettext('Explain options error'),
-              gettext("Error occurred while setting costs option in explain.")
+              gettext('Error occurred while setting costs option in explain.')
             );
-          }
+          },
         });
       },
 
       // This function will toggle "buffers" option in explain
-      _explain_buffers: function () {
+      _explain_buffers: function() {
         var self = this;
         if ($('.explain-buffers').hasClass('visibility-hidden') === true) {
           $('.explain-buffers').removeClass('visibility-hidden');
           self.explain_buffers = true;
-        }
-        else {
+        } else {
           $('.explain-buffers').addClass('visibility-hidden');
           self.explain_buffers = false;
         }
 
         // Set this option in preferences
         var data = {
-          'explain_buffers': self.explain_buffers
+          'explain_buffers': self.explain_buffers,
         };
 
         $.ajax({
-          url: url_for('sqleditor.query_tool_preferences', {'trans_id': self.transId}),
+          url: url_for('sqleditor.query_tool_preferences', {
+            'trans_id': self.transId,
+          }),
           method: 'PUT',
-          contentType: "application/json",
+          contentType: 'application/json',
           data: JSON.stringify(data),
-          success: function (res) {
+          success: function(res) {
             if (res.success == undefined || !res.success) {
               alertify.alert(gettext('Explain options error'),
-                gettext("Error occurred while setting buffers option in explain.")
+                gettext('Error occurred while setting buffers option in explain.')
               );
             }
           },
-          error: function (e) {
+          error: function() {
             alertify.alert(gettext('Explain options error'),
-              gettext("Error occurred while setting buffers option in explain.")
+              gettext('Error occurred while setting buffers option in explain.')
             );
-          }
+          },
         });
       },
 
       // This function will toggle "timing" option in explain
-      _explain_timing: function () {
+      _explain_timing: function() {
         var self = this;
         if ($('.explain-timing').hasClass('visibility-hidden') === true) {
           $('.explain-timing').removeClass('visibility-hidden');
           self.explain_timing = true;
-        }
-        else {
+        } else {
           $('.explain-timing').addClass('visibility-hidden');
           self.explain_timing = false;
         }
         // Set this option in preferences
         var data = {
-          'explain_timing': self.explain_timing
+          'explain_timing': self.explain_timing,
         };
 
         $.ajax({
-          url: url_for('sqleditor.query_tool_preferences', {'trans_id': self.transId}),
+          url: url_for('sqleditor.query_tool_preferences', {
+            'trans_id': self.transId,
+          }),
           method: 'PUT',
-          contentType: "application/json",
+          contentType: 'application/json',
           data: JSON.stringify(data),
-          success: function (res) {
+          success: function(res) {
             if (res.success == undefined || !res.success) {
               alertify.alert(gettext('Explain options error'),
-                gettext("Error occurred while setting timing option in explain.")
+                gettext('Error occurred while setting timing option in explain.')
               );
             }
           },
-          error: function (e) {
+          error: function() {
             alertify.alert(gettext('Explain options error'),
-              gettext("Error occurred while setting timing option in explain.")
+              gettext('Error occurred while setting timing option in explain.')
             );
-          }
+          },
         });
       },
 
       /*
        * This function will indent selected code
        */
-      _indent_selected_code: function () {
-        var self = this, editor = self.gridView.query_tool_obj;
-        editor.execCommand("indentMore");
+      _indent_selected_code: function() {
+        var self = this,
+          editor = self.gridView.query_tool_obj;
+        editor.execCommand('indentMore');
       },
 
       /*
        * This function will unindent selected code
        */
-      _unindent_selected_code: function () {
-        var self = this, editor = self.gridView.query_tool_obj;
-        editor.execCommand("indentLess");
+      _unindent_selected_code: function() {
+        var self = this,
+          editor = self.gridView.query_tool_obj;
+        editor.execCommand('indentLess');
       },
 
-      isQueryRunning: function () {
+      isQueryRunning: function() {
         return is_query_running;
       },
 
@@ -3674,7 +3748,7 @@ define('tools.querytool', [
        * This function get explain options and auto rollback/auto commit
        * values from preferences
        */
-      get_preferences: function () {
+      get_preferences: function() {
         var self = this,
           explain_verbose = false,
           explain_costs = false,
@@ -3682,7 +3756,7 @@ define('tools.querytool', [
           explain_timing = false,
           auto_commit = true,
           auto_rollback = false,
-          updateUI = function () {
+          updateUI = function() {
             // Set Auto-commit and auto-rollback on query editor
             if (auto_commit &&
               $('.auto-commit').hasClass('visibility-hidden') === true)
@@ -3725,9 +3799,11 @@ define('tools.querytool', [
           };
 
         $.ajax({
-          url: url_for('sqleditor.query_tool_preferences', {'trans_id': self.transId}),
+          url: url_for('sqleditor.query_tool_preferences', {
+            'trans_id': self.transId,
+          }),
           method: 'GET',
-          success: function (res) {
+          success: function(res) {
             if (res.data) {
               explain_verbose = res.data.explain_verbose;
               explain_costs = res.data.explain_costs;
@@ -3738,17 +3814,18 @@ define('tools.querytool', [
               updateUI();
             }
           },
-          error: function (e) {
+          error: function() {
             updateUI();
-            alertify.alert(gettext('Get Preferences error'),
-              gettext("Error occurred while getting query tool options.")
+            alertify.alert(
+              gettext('Get Preferences error'),
+              gettext('Error occurred while getting query tool options.')
             );
-          }
+          },
         });
       },
-      close: function () {
+      close: function() {
         var self = this;
-        _.each(window.top.pgAdmin.Browser.docker.findPanels('frm_datagrid'), function (panel) {
+        _.each(window.top.pgAdmin.Browser.docker.findPanels('frm_datagrid'), function(panel) {
           if (panel.isVisible()) {
             window.onbeforeunload = null;
             panel.off(wcDocker.EVENT.CLOSING);
@@ -3759,17 +3836,16 @@ define('tools.querytool', [
             window.top.pgAdmin.Browser.docker.removePanel(panel);
           }
         });
-      }
-    }
-  );
+      },
+    });
 
   pgAdmin.SqlEditor = {
     // This function is used to create and return the object of grid controller.
-    create: function (container) {
+    create: function(container) {
       return new SqlEditorController(container);
     },
     jquery: $,
-    S: S
+    S: S,
   };
 
   return pgAdmin.SqlEditor;
