<span style= "FONT-SIZE:18PX;" >var id = $ ("#newstable"). Jqgrid ("Getgridparam", "Selrow"); Single line var selectedid = $ ("#newstable"). Jqgrid ("Getgridparam", "Selarrrow"); // Jqgrid usage: Common attribute usage and implications 1. How to get the ID of the grid-selected row. JavaScript code var rowid = $ ( "#searchResultList" ). Getgridparam ( "Selrow" ); var rowid = $ ("#searchResultList"). Getgridparam ("Selrow"); 2. How to dynamically add a row of data to a table. JavaScript code //$ ("#jqgrid"). Addrowdata (Rowid, data, pos, &NBSP;IDX); //pos can be [first,last,before,after], for the latter two are required to specify a relative row id $ ( "# Jqgrid " ". Addrowdata ( "1" , { "name" : "Test" , "Age" :12}, "; " //$ ("#jqgrid "). Addrowdata (ROWID,&NBSP;DATA,&NBSP;POS,&NBSP;IDX); //pos can be [first,last,before,after], For the latter two is the need to specify a relative row id $ ("#jqgrid"). Addrowdata ("1", {"name": "Test", "Age":12}, "a"); 3. How to dynamically modify the data content of a row, such as the values of a few columns. JavaScript code //setrowdata ( rowid, data ); $ ( "#jqgrid" ). Setrowdata ( "1" , { tax: "5" , total: " 205 " }"; //setrowdata ( rowid, data ); $ ("#jqgrid"). Setrowdata ( "1", { tax: "5", total: "205"  }); 4. jqgrid Common Properties. JavaScript code $ ( "#jqgrid" ). Jqgrid ({ URL: "${ctx}/sys/role/search.dm" , colnames:[ "role name" ], //, "role Code" colmodel:[ "rolename" ], //"Rolecode" can also be replaced with objects jsonreader:{id: "Roleid" ,root: "dataList" }, width:240, height:250, rownum:20, //per page 20 records pager: " Loglistpager " , //paging divid sortname: " Actiontime " , //default sorted column names sortorder: "desc" , //the order of default ordering scroll: true , Mouse scrolling page onselectrow: function (ROWID) {} }); $ ("#jqgrid"). Jqgrid ({ URL: "${ctx}/sys/role/search.dm", colnames:["role name"],//, "role Code" colmodel:["rolename"],//"Rolecode" can also be replaced with object jsonreader:{id: "Roleid", Root: "DataList"}, width:240, height:250, rownum:20,//per page 20 records pager: " Loglistpager ",//pagination display divid sortname: " actiontime ",//default sorted column name sortorder: " desc ", Order of default sort &nbsP scroll:true,//Mouse Scrolling page onselectrow: function (ROWID) {} }); 5. Gets the data object for a row. JavaScript code var rowid = $ ( "#searchResultList" ). Getgridparam ( "Selrow" ); var rowdata = $ ( "# Searchresultlist " ). GetRowData (ROWID); var rowid = $ (" #searchResultList ") . Getgridparam ("Selrow"); var rowdata = $ ("#searchResultList"). GetRowData (ROWID); 6. How to use the API to dynamically modify selected rows. JavaScript code //true: Reload table data, false: Do not reload table data $ ( "#jqGrid" ). SetSelection ( "1" , true ); //true: Reload Tabular data, false: Do not reload table data $ ("#jqGrid"). SetSelection ("1", true); 7. How to get the value of a column JavaScript code Var col= jquery ("#jqGrid "). Jqgrid (' Getcol ', 4,false);//Get the value of the 4th column var Col= jquery ("#jqGrid "). Jqgrid (' Getcol ', ' name ', false);//Get the value of the column named name 8. How to delete one or more lines var selectedid = $ ("#gridTable"). Jqgrid ("Getgridparam", " Selrow "); $ (" #gridTable "). Jqgrid (' Delrowdata ', selectedid); also has the following commonly used api, JavaScript code $ ( "#jqgrid" ). resetselection (); $ ( "#jqgrid" ). Cleargriddata (); $ ( "#jqgrid" ). Setcell (ROWID,COLNAME,NDATA,CSSP,ATTRP); </span>
Source: https://blog.csdn.net/jingmeifeng/article/details/8129414