This method uses colModel and editurl parameters from jqGrid
Calling Convention:
jQuery("#grid_id").delGridRow( row_id_s, options );
where
| Property | Description | Default |
|---|---|---|
| top | the initial top position of confirmation dialog | 0 |
| left | the initial left position of confirmation dialog | 0 |
| width | the width of confirmation dialog | 300 |
| height | the height of confirmation dialog | 200 |
| modal | sets dialog in modal mode | false |
| drag | the dialog is dragable | true |
| msg | message to display when deleting the row | "Delete selected row(s)" |
| caption | the caption of the dialog | "Delete Record" |
| bSubmit | the text of the button when you click to delete | "Delete" |
| bCancel | the text of the button when you click to close dialog | "Cancel" |
| url | url where to post data. If set, replaces the editurl | |
| reloadAfterSubmit | reload grid data after posting | true |
| delData | an array used to add content to the data posted to the server | empty |
| Event | Description | Default |
|---|---|---|
| beforeShowForm | fires before showing the form; receives as Parameter the id of the constructed form. | null |
| afterShowForm | fires after showing the form; receives as Parameter the id of the constructed form. | null |
| beforeSubmit | fires before the data is submitted to the server. Parameter is of type id=value1,value2,... When called the event can return array where the first parameter can be true or false and the second is the message of the error if any. Example: [false,"The value is not valid"]
|
null |
| onclickSubmit | fires after the submit button is clicked and the postdata is constructed. Parameters passed to this event is a options array of the method. The event should return array of type {} which then replaces the data of delData. See example below. | null |
| afterSubmit | fires after response has been received from server. Typically used to display status from server (e.g., the data is successfully deleted or deletion cancelled for referential integrity reasons). Receives as parameters the data returned from the request and an array of the posted values of type id=value1,value2 | null |
If the top and left off-set properties are not set, the dialog appears at the upper left corner of the grid. Top and left off-sets are in relation to the viewing window, not the grid, so {top:10, left:10} will be indented slightly from the window, and may be nowhere near the grid.
We can set common options for all delete dialogs using the $.jgrid.del object with $.extend().
The default values are:
jQuery.jgrid.del = { caption: "Delete", msg: "Delete selected record(s)?", bSubmit: "Delete", bCancel: "Cancel", processData: "Processing..." };
Using onclickSubmit:
This feature can be used to add data to that which is to be sent to the server.
Static method (can be used in navigator too)
jQuery("#grid_id").delGridRow("rowid",{delData:{myname:"myvalue"}});
Every time when the data is sent to the server this pair will be added to the postdata.
If we want to dynamically add data to that sent to the server, we can use something like the following:
onclickSubmit : function(eparams) { var retarr = {}; // we can use all the grid methods here //to obtain some data var sr = jQuery("#grid_id").getGridParam('selrow'); rowdata = jQuery("#grid_id").getRowData(sr); if(rowdata.somevalue=='aa') { retarr = {myname:"myvalue"}; } return retarr; }
If the condition is true the pair myname:myvalue will be sent to the server when you click submit.