how to save an entire object in a variable on a kendo autocomplete selection -


i need kendo autocomplete widget... maybe stupid question, can't reach solution!!! kendoautocomplete widget, gets data c# webservice:

 [scriptmethod(responseformat = responseformat.json, usehttpget = false)]  [webmethod]     public string getcomunilist()     {         using (printinvoicesdatacontext context = new printinvoicesdatacontext())         {             list<comuni_italia> comuni = new list<comuni_italia>();             comuni = context.comuni_italia.tolist();              var jsonstr = jsonconvert.serializeobject(comuni, formatting.indented);             return jsonstr;         }      } 

this method returns long object array this:

[  {id_comune: 1, des_comune: "milano", cod_comune: "a130", cap_comune: "64022"},    {id_comune: 2, des_comune: "torino", cod_comune: "a131", cap_comune: "64100"},    .... ] 

so, when choose item kendo autocomplete widget, on select event, need save whole selected object in variable.

var comuneautocomplete = $("#comune_w").kendoautocomplete({     minlength: 3,     datasource: datasource,     placeholder: "inserisci comune...",     datatextfield: "des_comune",     datavaluefield: "id_comune" }).data("kendoautocomplete").bind("select", function (data) {     //here want save object     var comune = ???????? }); 

so fields values this:

var id_com = comune.id_comune; var des_com = comune.des_comune; .......... 

this model of datasource:

model: {     fields: {         id: "id_comune",         id_comune: { type: "string" },         des_com: { type: "string" },         des_prv: { type: "string" },         des_reg: { type: "string" },         cod_com: { type: "string" },         cod_prv: { type: "string" },         cod_res: { type: "string" }     } 

is possible?? hope can me! in advance.

getting data datasource selected item is:

var comuneautocomplete = $("#comune_w").kendoautocomplete({     minlength: 3,     datasource: datasource,     placeholder: "inserisci comune...",     datatextfield: "des_comune",     datavaluefield: "id_comune" }).data("kendoautocomplete").bind("select", function (data) {     //here want save object     var comune = this.dataitem(e.item.index());     ... }); 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -