Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
wiki:methods [2012/08/09 20:39]
gam3 grammer
wiki:methods [2017/12/09 14:40]
admin
Line 3: Line 3:
 This chapter describes the basic methods of jqGrid. Some methods require that additional modules should be loaded. \\  This chapter describes the basic methods of jqGrid. Some methods require that additional modules should be loaded. \\ 
 As of version 3.6 jqGrid uses new API which is compatible with jQuery UI library. See below. As of version 3.6 jqGrid uses new API which is compatible with jQuery UI library. See below.
-See also [[wiki:​events|jqGrid Events]].+See also [[wiki:​events|jqGrid Events]]
 ===== Grid Related Methods ===== ===== Grid Related Methods =====
  
Line 65: Line 65:
 <​head>​ <​head>​
 <meta http-equiv="​Content-Type"​ content="​text/​html;​ charset=utf-8"​ /> <meta http-equiv="​Content-Type"​ content="​text/​html;​ charset=utf-8"​ />
 +<meta http-equiv="​X-UA-Compatible"​ content="​IE=edge"​ />
 <​title>​My First Grid</​title>​ <​title>​My First Grid</​title>​
   ​   ​
Line 99: Line 100:
 |clearGridData|clearfooter|jqGrid object| Clears the currently loaded data from grid. If the clearfooter parameter is set to true, the method clears the data placed on the footer row.| |clearGridData|clearfooter|jqGrid object| Clears the currently loaded data from grid. If the clearfooter parameter is set to true, the method clears the data placed on the footer row.|
 |delRowData|rowid|true on success, \\ false otherwise|Deletes the row with the id = //rowid//. This operation does not delete data from the server.| |delRowData|rowid|true on success, \\ false otherwise|Deletes the row with the id = //rowid//. This operation does not delete data from the server.|
 +|editRow|rowid,​\\ keys\\ | none? |Edits the row specified by **rowid**. **keys** is a boolean value, indicating if to use the Enter key to accept the value ane Esc to cancel the edit, or not.|
 |footerData|action,​\\ data, \\ format|jqGrid object|This method gets or sets data on footer. See footerrow in [[options]] array.\\ //action// - can be '​get'​ or '​set'​. The default is get. '​get'​ returns an object of type name:value, where the name is a name from colModel. This will return data from the footer. The other two options have no effect in this case. \\ '​set'​ takes a //data// array (object) and places the values in the footer. The object should be in name:value pair, where the name is the name from colModel\\ //format// - default is true. This instruct the method to use the formatter (if set in colModel) when new values are set. A value of false will disable the using of formatter| |footerData|action,​\\ data, \\ format|jqGrid object|This method gets or sets data on footer. See footerrow in [[options]] array.\\ //action// - can be '​get'​ or '​set'​. The default is get. '​get'​ returns an object of type name:value, where the name is a name from colModel. This will return data from the footer. The other two options have no effect in this case. \\ '​set'​ takes a //data// array (object) and places the values in the footer. The object should be in name:value pair, where the name is the name from colModel\\ //format// - default is true. This instruct the method to use the formatter (if set in colModel) when new values are set. A value of false will disable the using of formatter|
 |getCell|rowid,​ \\ iCol|cell content| Returns the content of the cell specified by id = //rowid// and column = //iCol//. iCol can be either the column index or the name specified in colModel.\\ <color red>Do not use this method when you are editing the row or cell. This will return the cell content and not the actuall value of the input element </​color>​| |getCell|rowid,​ \\ iCol|cell content| Returns the content of the cell specified by id = //rowid// and column = //iCol//. iCol can be either the column index or the name specified in colModel.\\ <color red>Do not use this method when you are editing the row or cell. This will return the cell content and not the actuall value of the input element </​color>​|
Line 110: Line 112:
 |remapColumns|permutation,​ updateCells,​ keepHeader|none|Reorder the grid columns based on the permutation array. The indexes of the //​permutation//​ array are the current order, the values are the new order. By example if the array has values [1,0,2] after calling this method the first column will be reordered as second. //​updateCells//​ if set to true will reorder the cell data. //​keepHeader//​ if set to true will reorder the data above the header cells.| |remapColumns|permutation,​ updateCells,​ keepHeader|none|Reorder the grid columns based on the permutation array. The indexes of the //​permutation//​ array are the current order, the values are the new order. By example if the array has values [1,0,2] after calling this method the first column will be reordered as second. //​updateCells//​ if set to true will reorder the cell data. //​keepHeader//​ if set to true will reorder the data above the header cells.|
 |resetSelection|none|jqGrid object|Resets (unselects) the selected row(s). Also works in multiselect mode.| |resetSelection|none|jqGrid object|Resets (unselects) the selected row(s). Also works in multiselect mode.|
 +|restoreRow|rowid|none?​|Restores the data to original values before the editing of the row specified by **rowid**.|
 +|saveRow|rowid,​\\ callback,\\ url,\\ extraparams\\ |none?​|Saves the row specified by **rowid**, after it has been opened for editing mode by the editRow method. **callback** is a function called after the save is complete. The function accepts an XMLHttpRequest object with the response from the server. **url** is the URL used to submit the values. If specified, this value overrides the value specified by the [[options|editurl]] option. **extraparas** are additional parameters passed to the server. Data is posted in the form  id=rowid&​name=value...,​ where the name is the "​name"​ from [[colmodel_options|colModel]].|
 |setCaption|caption|jqGrid object|Sets a new caption of the grid. If the Caption layer was hidden, it is shown.| |setCaption|caption|jqGrid object|Sets a new caption of the grid. If the Caption layer was hidden, it is shown.|
 |setCell|rowid,​\\ colname, \\ data, \\ class, \\ properties, \\ forceup|jqGrid object|This method can change the content of particular cell and can set class or style properties. Where: \\ //rowid// the id of the row, \\ //colname// the name of the column (this parameter can be a number (the index of the column) beginning from 0 \\ //data// the content that can be put into the cell. If empty string the content will not be changed \\ //class// if class is string then we add a class to the cell using addClass; if class is an array we set the new css properties via css \\ //​properties//​ sets the attribute properies of the cell, \\ //forceup// If the parameter is set to true we perform update of the cell instead that the value is empty | |setCell|rowid,​\\ colname, \\ data, \\ class, \\ properties, \\ forceup|jqGrid object|This method can change the content of particular cell and can set class or style properties. Where: \\ //rowid// the id of the row, \\ //colname// the name of the column (this parameter can be a number (the index of the column) beginning from 0 \\ //data// the content that can be put into the cell. If empty string the content will not be changed \\ //class// if class is string then we add a class to the cell using addClass; if class is an array we set the new css properties via css \\ //​properties//​ sets the attribute properies of the cell, \\ //forceup// If the parameter is set to true we perform update of the cell instead that the value is empty |
Line 115: Line 119:
 |setGridHeight|new_height|jqGrid object|Sets the new height of the grid dynamically. Note that the height is set only to the grid cells and not to the grid. //​new_height//​ can be in pixels, percentage, or '​auto'​.| |setGridHeight|new_height|jqGrid object|Sets the new height of the grid dynamically. Note that the height is set only to the grid cells and not to the grid. //​new_height//​ can be in pixels, percentage, or '​auto'​.|
 |setGridWidth|new_width,​\\ shrink|jqGrid object|Sets a new width to the grid dynamically. The parameters are: \\ //​new_width//​ is the new width in pixels.\\ //shrink (true or false)// has the same behavior as shrinkToFit - see [[options]]. If this parameter is not set we take the value of shrinkToFit.| |setGridWidth|new_width,​\\ shrink|jqGrid object|Sets a new width to the grid dynamically. The parameters are: \\ //​new_width//​ is the new width in pixels.\\ //shrink (true or false)// has the same behavior as shrinkToFit - see [[options]]. If this parameter is not set we take the value of shrinkToFit.|
-|setLabel| colname, \\ data, \\ class, \\ properties|jqGrid object|Sets a new label in the header for the specified column; can also set attributes and classes . The parameters are: \\ //colname// the name of the column (this parameter can be a number (the index of the column) beginning from 0 \\ //data// the content that can be put into the label. If empty string the content will not be changed \\ //class// if class is string then we add a class to the label using addClass; if class is an array we set the new css properties via css \\ //​properties//​ sets the attribute properies of the label|+|setLabel| colname, \\ data, \\ class, \\ properties|jqGrid object|Sets a new label in the header for the specified column; can also set attributes and classes . The parameters are: \\ //colname// the name of the column ​from colModel(this parameter can be a number (the index of the column) beginning from 0 \\ //data// the content that can be put into the label. If empty string the content will not be changed \\ //class// if class is string then we add a class to the label using addClass; if class is an array we set the new css properties via css \\ //​properties//​ sets the attribute properies of the label|
 |setRowData|rowid,​\\ data, \\ cssprop|true on success, \\ false otherwise|Updates the values (using the //data// array) in the row with //rowid//. The syntax of data array is: {name1:​value1,​name2:​ value2…} where the name is the name of the column as described in the colModel and the value is the new value. \\ If the cssprop parameter is string we use addClass to add classes to the row. If the parameter is object we use css to add css properties. Note that we can set properties and classes without data, in this case we should set data to false \\ <color red>Do not use this method when you are editing the row or cell. This will set the content and overwrite the input elements.</​color>​ \\| |setRowData|rowid,​\\ data, \\ cssprop|true on success, \\ false otherwise|Updates the values (using the //data// array) in the row with //rowid//. The syntax of data array is: {name1:​value1,​name2:​ value2…} where the name is the name of the column as described in the colModel and the value is the new value. \\ If the cssprop parameter is string we use addClass to add classes to the row. If the parameter is object we use css to add css properties. Note that we can set properties and classes without data, in this case we should set data to false \\ <color red>Do not use this method when you are editing the row or cell. This will set the content and overwrite the input elements.</​color>​ \\|
 |setSelection|rowid,​\\ onselectrow|jqGrid object|Toggles a selection of the row with id = //rowid//; if //​onselectrow//​ is true (the default) then the event onSelectRow is launched, otherwise it is not.| |setSelection|rowid,​\\ onselectrow|jqGrid object|Toggles a selection of the row with id = //rowid//; if //​onselectrow//​ is true (the default) then the event onSelectRow is launched, otherwise it is not.|

QR Code
QR Code wiki:methods (generated for current page)