9
I am new to jqgrid. I have the following code to insert a new row when a tab key is pressed. It works for the most part of it. But when a new row is inserted, the focus is given to the second Column in that row instead of First column.
How do I solve this problem??
HTML:
<table id="list11"></table>
<!--<div id="paddtree"></div>-->
<label>press tab to add new row</label>
<script>
var selIRow = 1;
var lastsel2
jQuery("#list11").jqGrid({
// url:'d/${jobId}.htm',
datatype: "json",
colNames: ['First Name', 'Email ID', 'Phone Number'],
colModel: [
// {name:'id',index:'id', width:75, search:true, stype:'text' , search:true, sortable:true},
{name: 'firstName', width: 180, search: true, stype: 'text', sortable: true, editable: true, },
{name: 'email', index: 'email', width: 250, editable: true},
{name: 'phoneNumber', index: 'phoneNumber', width: 100, align: "right", editable: true,
editoptions: {
dataInit: function(elem) {
$(elem).focus(function() {
this.select();
})
},
dataEvents: [
{
type: 'keydown',
fn: function(e) {
var key = e.charCode || e.keyCode;
if (key == 9 || key == 15)//tab
{
var grid = $('#list11');
//Save editing for current row
grid.jqGrid('saveRow', selIRow, false, 'clientArray');
//If at bottom of grid, create new row