jquery - jEditable - Edit data with drop down -


i using datatables + jeditable display data db , allow user edit each cell directly.

currently able implement inline edit , save updated value database text field , datepicker, however, met problem data need allow edit drop down.

the value need edit retrieve db table foreign key relationship.

 <td id="type@(item.foodid)" class="dropdown">      @html.displayfor(modelitem => item.foodtypes.foodtypename)  </td> 

i follow guide http://gunbladeiv.blogspot.com/2011/06/part-2-mvc-3-and-datatables-with-inline.html using action return list of selection json:

 function getfoodtypeslist() {     var list;     $.post('getfoodtypes', {},         function (data) {             list = validatejson(data);         },         'json/javascript'     );     return list; }  function validatejson(x) {     var orig = x;     var stgify = json.stringify(orig);     var splitchar = ['\\"', '\',\'', '[', ']', '\"'];     var joinchar = ['\'', '\':\'', '', '', ''];      (i = 0; < 5; i++) {         stgify = stgify.split(splitchar[i]);         tmp = stgify.join(joinchar[i]);         stgify = tmp;     }     stgify = "{" + stgify + "}";     var finaledit = stgify;     return finaledit; }  

question: not understand use of "validatejson" method include example

when try click on field, javascript error firebug: "xxx" not defined (xxx foodtypename)

if change view :

<td id="type@(item.foodid)" class="dropdown">     @html.displayfor(modelitem => item.foodtypeid) </td> 

the error gone empty dropdown.

really need here....

i able modify validatejson function according situation , work! in case looking solution, post method here:

// function format food type list plugin required json format function validatejson(x) {     var orig = x;      // split , cover each array item "" , join :     (i = 0; < orig.length; i++) {         var temp = orig[i].tostring();         var temparray = temp.split(",");         (j = 0; j < temparray.length; j++) {             temparray[j] = "\"" + temparray[j].tostring() + "\"";         }         orig[i] = temparray.join(":");     }      // original validatejson method website     var stgify = json.stringify(orig);     var splitchar = ['\\"', '\',\'', '[', ']', '\"'];     var joinchar = ['\'', '\':\'', '', '', ''];      (i = 0; < 5; i++) {         stgify = stgify.split(splitchar[i]);          tmp = stgify.join(joinchar[i]);         stgify = tmp;     }      stgify = "{" + stgify + "}";     var finaledit = stgify;     return finaledit; } 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -