64534

Can I have the cursor start on a particular column by default in jqgrid's edit mode?

When editing a row on jqgrid, the cursor automatically enters the left-most editable field. Is there a way to have it default to a particular column, or better yet, to whatever column I click on?

Answer1:

The implementation depend on the version of jqGrid and from the fork of jqGrid which you use.

If you use the latest version of free jqGrid then the code

onSelectRow: function (rowid, status, e) { var $self = $(this), savedRow = $self.jqGrid("getGridParam", "savedRow"); if (savedRow.length > 0 && savedRow[0].id !== rowid) { $self.jqGrid("restoreRow", savedRow[0].id); } $self.jqGrid("editRow", rowid, { focusField: e.target }); }, inlineEditing: { keys: true, defaultFocusField: "amount", focusField: "amount" }

see the demo. The above code uses e.target as the value of focusField property of jqGrid method editRow. As the result the focus will be set on the clicked cell. If the user clicks on non-editable cell, like on "rownumber" column for example, then the option defaultFocusField will be used and the focus will be set on the column "amount". I remind that free jqGrid uses inlineEditing option to specify default parameters of inline editing (see the wiki article for more details).

The option focusField of editRow is supported starting with version 4.7, but old version support only boolean and number values.

Recommend

  • How to access the fields of a jqGrid row?
  • my Android ContentProvider can't find ContentResolver
  • Delete rows matching substring with LIKE?
  • Why can I not read from stdin in this forked process?
  • How do you increment a count while using the sleep function?
  • How can you use last_insert_rowid to insert multiple rows?
  • Using Node cluster module with SailsJs: EADDRINUSE
  • Associate git repo with existing fork network
  • Jenkins Grails plugin does not list lastest versions of Grails
  • How to get links to open in the native browser in iOS Meteor apps?
  • SQL Query - Table Joining Problems
  • Can't remove headers after they are sent
  • gspread or such: help me get cell coordinates (not value)
  • Stop Bash Script if Hive Fails
  • How to use JavaScript to determine whether a file exists in a directory?
  • C: Incompatible pointer type initializing
  • How do I pass the string value parameter of the selected list item from an auto-populated dropdown l
  • why overloaded new operator is calling constructor even I am using malloc inside overloading functio
  • Google Custom Search with transparent background
  • The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin' does not exist or no valid ver
  • Why value captured by reference in lambda is broken? [duplicate]
  • JavaScriptCore crash on iOS9
  • Obtain ObjectIdHex value from mgo query
  • Volusion's generic SQL folder, functionality
  • How to set/get protobuf's extension field in Go?
  • JSON with duplicate key names losing information when parsed
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Circular dependency while pushing http interceptor
  • Linker errors when using intrinsic function via function pointer
  • How to delete a row from a dynamic generate table using jquery?
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • using HTMLImports.whenReady not working in chrome
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • How to stop GridView from loading again when I press back button?
  • Authorize attributes not working in MVC 4
  • EntityFramework adding new object to nested object collection
  • Binding checkboxes to object values in AngularJs
  • Net Present Value in Excel for Grouped Recurring CF
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?