Jqgrid Common Properties and methods

Source: Internet
Author: User
<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 "&nbsp}";   //setrowdata ( rowid, data );   $ ("#jqgrid"). Setrowdata (   "1",  { tax: "5",  total: "205" &nbsp});      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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.