Introduction to jqgrid
Jqgrid is a jquery-based Web-side table/tree grid component.
Official Website:
Http://www.jqgrid.com
Default select definition method
{Name: 'ship ', index: 'ship', width: 90, Editable: True, edittype: "select", editoptions: {value: "Fe: FedEx; in: intime; TN: TNT; AR: aramex "}}
The default definition method is to set the col definition of colmodel in the definition options of grid.
Fe: FedEx => the colon is preceded by value and followed by text.
After this setting, the options of all the drop-down lists under the same column are the same. How do I set different options for this field of each row?
Datatype is not local. If it is local, the implementation is as follows:
Customized implementation
Colmodel Definition
{Name: 'note', index: 'note', Editable: True, edittype: 'custom', editoptions: {custom_element: myelem, custom_value: myvalue}, width: 150, sortable: false}]
JavaScript function definition
Function myelem (value, options) {var El = Document. createelement ("select"); If (value! = NULL & value. length> 0) {var optvalues = eval (value); If (optvalues. length> 0) {for (VAR I = 0; I <optvalues. length; I ++) {var optvalue = optvalues [I]. optvalue; var optdisplay = optvalues [I]. optdisplay; var Optel = document. createelement ("option"); Optel. innerhtml = optdisplay; Optel. value = optvalue; El. appendchild (Optel) ;}}return El;} function myvalue (ELEM, operation, value) {If (Operation === 'get') {return $ (ELEM ). val ();} else if (Operation = 'set') {$ (ELEM ). val (value );}}
When adding data, the value of this field is assigned in JSON format:
{Optvalue: 'value', optdisplay: 'display '}