Jqgrid internal methods

Source: Internet
Author: User
Tags jqgrid

The jqgrid method is fully compatible with the jquery UI library from 3.6.

Jquery ("# grid_id"). jqgridmethod (parameter1,... parametern );

Jquery ("# grid_id"). setgridparam ({...}). hidecol ("somecol"). Trigger ("reloadgrid ");

If you use the new API:

Jquery ("# grid_id"). jqgrid ('method', parameter1,... parametern );

Jquery ("# grid_id"). jqgrid ('setgridparam', {...}). jqgrid ('hidecol', "somecol"). Trigger ("reloadgrid ");

Jqgrid configuration uses the new API

· <! Doctype HTML public "-// W3C // dtd xhtml 1.0 strict // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

· <HTML xmlns = "http://www.w3.org/1999/xhtml" XML: lang = "en" lang = "en">

· <Head>

· <Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>

· <Title> my first grid </title>

·

· <LINK rel = "stylesheet" type = "text/CSS" Media = "screen" href = "CSS/UI-lightness/jquery-ui-1.7.1.custom.css"/>

· <LINK rel = "stylesheet" type = "text/CSS" Media = "screen" href = "CSS/ui.jqgrid.css"/>

·

· <SCRIPT src = "JS/jquery-1.3.2.min.js" type = "text/JavaScript"> </SCRIPT>

· <SCRIPT src = "JS/i18n/grid. locale-en.js" type = "text/JavaScript"> </SCRIPT>

· <SCRIPT type = "text/JavaScript">

· Jquery. jgrid. no_legacy_api = true;

· </SCRIPT>

· <SCRIPT src = "JS/jquery. jqgrid. Min. js" type = "text/JavaScript"> </SCRIPT>

·

· </Head>

· <Body>

·...

· </Body>

· </Html>

 

Jqgrid Method

Method Name

Parameters

Return Value

Description

Addjsondata

Data

None

Fill the table with incoming data. Usage:

VaR mygrid = jquery ("#" + grid_id) [0];

VaR myjsongrid = eval ("(" + jsonresponse. responsetext + ")"); mygrid. addjsondata (myjsongrid );

Myjsongrid = NULL;

Jsonresponse = NULL;

Addrowdata

Rowid, Data, position, srcrowid

Success is true; otherwise, false.

Insert a new row of data according to the parameter. rowid is the ID of the new row, data is the data of the new row, position is the location of the new row, and srcrowid is the reference location of the new row. Data format: {name1: value1, name2: value2 ...} Name is the name specified in colmodel.

Addxmldata

Data

None

Fill the table according to the incoming data. Usage: var mygrid = jquery ("#" + grid_id) [0]; mygrid. addxmldata (xmlresponse. responsexml );

Cleargriddata

Clearfooter

Jqgrid object

Clears the data currently loaded from the table. If clearfooter is true, this method deletes the data in the last row of the table.

Delrowdata

Rowid

Success: true; otherwise, false.

Deletes a row based on rowid, but does not delete data from the server.

Footerdata

Action, Data, format

Jggrid object

Set or obtain the bottom data. Action: "Get" or "set". The default value is "get". If it is "get", the return value is name: value, and name is the name in colmodel. If it is set, the value is name: value, and name is the name in colmodel. Format: The default value is true. When the value is true, the formatter format value is called when the new value is set.

Getcell

Rowid, icol

Cell content

Return the content of the specified rowid and icol cell. icol can be either the position index of the current column in colmodel or the name value. Note: you cannot use this method when editing rows or cells. In this case, the returned value is not a changed value, but the original value.

Getcol

Colname, returntype, mathoperation

Array [] or value

Returns the value of a column. Colname can be the index or name value of the current column in colmodel. Returntype specifies the type of returned data. The default value is false. If the value is false, the returned array only contains the column value. If the value is true, the returned array is an object array in the format of {ID: rowid, value: cellvalue }, ID is the row ID and value is the column value. For example, [{ID: 1, value: 1}, {ID: 2, value: 2}…]. The optional mathoperation values are 'sum, 'avg', and 'Count'

Getdataids

None

Array []

Returns the ID of all data in the current grid.

Getgridparam

Name

Mixed Value

Return request parameter information

Getind

Rowid, rowcontent

Mixed

If rowcontent is false, the index location of the row is returned. The ID is the row ID. Rowcontent is false by default. If rowconent is true, the row object is returned. If no row is found, false is returned.

Getrowdata

Rowid or none

Array []

Return the data of the specified row. The returned data type is name: value, name is the name in colmodel, and value is the value of the column in the row. If no value is found based on rowid, null is returned. This method cannot be used to obtain data in editing mode. It does not obtain the edited value.

Hidecol

Colnameor [colnames]

Jqgrid object

If the parameter is a column name, this column is hidden. If an array is specified, all specified columns are hidden. Format: ["name1", "name2"]

Remapcolumns

Permutation, updatecells, keepheader

None

Adjust the display order of table columns. permutation is the order of the current column. If the value is [, 2], the first column is displayed in the second place. If updatecells is true, the cell data is reordered. If keepheader is true, the position of the header data is adjusted.

Resetselection

None

Jqgrid object

Selecting or reselect row data also works in the multiple-choice mode.

Setcaption

Caption

Jqgrid object

Set table title

Setcell

Rowid, colname, Data, class, Properties

Jqgrid object

Change the value of a cell. Rowid: ID of the current row; colname: column name. It can also be a column Location index starting from 0. Data: changes the content of cells. If it is empty, it is not updated. class: if it is a string, the addclass method will be used to add it to the CSS of the cell, if it is an array, it will be directly added to the style attribute; properties: Set the cell attribute

Setgridparam

Object

Jqgrid object

Set grid parameters. Some parameter modifications take effect only after the grid is reloaded. This method overwrites the event.

Setgridheight

New_height

Jqgrid object

The height of the grid can be dynamically changed. You can only set the height of a cell, but not the height of a table. New_height: pixel value, percentage, or "Auto"

Setgridwidth

New_width, shrink

Jqgrid object

Dynamically change the table width. New_width: Table width, pixel value; shrink: true or false, same as shrinktofit

Setlabel

Colname, Data, class, Properties

Jqgrid object

Set a new display name for the specified column. Colname: column name, which can also be the position index of a column, starting from 0; Data: Column Display name. If it is null, It is not modified; class: if it is a string, the addclass method will be used to add it to the CSS of the cell, if it is an array, it will be directly added to the style attribute; properties: Set the label attribute

Setrowdata

Rowid, Data, cssprop

Success true otherwise false

Update the value of a row. rowid is the row ID. Data Value format: {name1: value1, name2: value2 ...} Name is the name in colmodel; cssprop: if it is a string, it will be added to the CSS of the row using the addclass method. If it is an array or an object, it will be directly added to the style attribute.

Setselection

Rowid, onselectrow

Jqgrid object

Select or reselect the specified row. If onselectrow is true, the event onselectrow is triggered, and onselectrow is true by default.

Showcol

Colname

Jqgrid

Show columns. Colname can be an array ["name1", "name2"], but name1 or name2 must be the name in colmodel.

Trigger ("reloadgrid ")

None

Jqgrid object

Reload the current table and initiate a new request to the server.

Updatecolumns

None

None

Synchronize the width of a table. When dragging a table, use VaR mygrid = jquery ("# grid_id") [0]; mygrid. updatecolumns ();

 

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.