jquery - gridname.getGridParam('selrow') is null -


i have code below. please let me know how can selected row data in jqgrid.

i tried using below code:

function getlist() {        var grid = $("#gridname");     var rowkey = grid.getgridparam('selrow');     if (rowkey)         alert("selected row primary key is: " + rowkey);     else         alert("no rows selected"); } 

here getting "rowkey" null.

this function have used load json data jqgrid:

function loadvalues() {             $("#gridname").jqgrid({             datastr: mydatas,             datatype: "jsonstring",             jsonreader: {repeatitems: false},             autoencode:true,             caption: " ",             pgbuttons : false,             viewrecords : false,             pgtext : "",             pginput : false,             rownumbers:true,             cmtemplate: {sortable:false},             loadonce: true,             cellsubmit : "clientarray",              colnames: ['col1','col2'],             colmodel: [{                 name: 'col1',                 index: 'col1',                 width: 0             },{                 name: 'col2',                 index: 'col2',                 width: 0             }           }]         });     } 

the call var rowkey = grid.getgridparam('selrow'); (where var grid = $("#gridname");) can set variable rowkey null in 2 cases:

  1. you execute code before jqgrid created empty table <table id="gridname"></table>. have same results if there no element id="gridname" @ all.
  2. it's no row selected in grid @ moment of executing of code.

you posted separate code of getlist , loadvalues functions. it's difficult problem have.

by way, function loadvalues can executed only once. creates grid empty <table id="gridname"></table>. during creating modified in relatively complex structure of dives , tables. 1 can't call function loadvalues more once. during next call jqgrid tests, grid created , nothing. if want recreate grid in function loadvalues should add $("#gridname").jqgrid("gridunload"); @ beginning.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -