javascript - How to add dynamic dropdown values in jQgrid? -
in editoptions select dropdown pass static values after instantiate of grid_data. works fine until choose editing. data remains constant , static.
all dropdown remains same. should not happen, has load appropriate data rows should dynamic.
var data = { "id" : "citygrid", "grid_data" : response, "colnames" : ['city name','select state','local'], "colmodel": [ {"name":'cityname',"index":'cityname', "width":150,"editable": true,"editoptions":{"size":"20","maxlength":"30"}}, {"name":'selectstate',"index":'selectstate',"width":90,"editable": true,"edittype":"select","editoptions":{"value":"tn:tamilnadu;ap:andhrapradesh;mp:madhyapradesh", "class":"chosen-select","width":200,"custom":true,"custom_func":util.applychosen}}, {"name":'local',"index":'local', "width":70, "editable": true,"edittype":"checkbox","editoptions": {"value":"yes:no"},"unformat": "aceswitch"} ], "editurl": "/dummy.html", "caption": "city information" };
"editoptions":{"value":"tn:tamilnadu;ap:andhrapradesh;mp:madhyapradesh"
i came across dataurl passing after few search results. not upto mark need send param not possible there.
and thought of taking value of 1 particular row data , make select on top , load rest of static use chosen form of data triggers on keypress , problem solve. problem here editing 2 types 1 single row , multirow.
this phase got struck. has solved problem. new version of jqgrid has answer problem?
thanks in advance
first of can generate dataurl
dynamically based. easiest way define dataurl
callback function: dataurl: function (rowid, value, name) { ... }
.
on other side seems need generate select <option>
value
not same displayed text: <option value="tn">tamilnadu</option>
. in case value tn
saved in column after editing , should hold (to fill) corresponding column data tn
, ap
, mp
instead of tamilnadu
, andhrapradesh
, madhyapradesh
. should use formatter: "select"
(see here) display input values tn
, ap
, mp
tamilnadu
, andhrapradesh
, madhyapradesh
. formatter formatter: "select"
uses formatoptions.value
or (it it's not defined) editoptions.value
value. 1 have able set editoptions.value
(or formatoptions.value
or both) before grid content created, before server response processed jqgrid.
to able set editoptions.value
dynamically 1 can use setcolprop
method. if loads data server 1 can include column property exception name
property in server response. 1 can inside of beforeprocessing
callback example. the answer this one , this one describe approach detailed. the answer shows how 1 can use common column name
property ("c1", "c2", "c2") , uses jsonmap
read relatively common named data. 1 can set jsonmap
instead of name
property if it's needed.
Comments
Post a Comment