javascript - Concat two method calls in javacript -
i have method use code populate dropdown lists like:
function fillselectcatalog(method, controlname, valuename, textname, assignvalue) { try { $(function () { $.ajax({ cache: false, type: "post", datatype: "json", url: '../catalogo/' + method, contenttype: "application/json; charset=utf-8", success: function (response) { fillselect(controlname, response, valuename, textname, assignvalue); }, error: function (response) { errormessage("error", gettexterror(response)); } }); }); } catch (e) { errormessage("error", e.message); } }
so jquery call dropdown like:
fillselectcatalog("getactivemeter", "meterenergy", "id", "meter1", null);
in dropdown
meterenegry1, meterenergy2, etc
and want concat fillselectcatalog "meterenergy1 - water"
, possible?
there fillselectcatalog "water" value want concat:
fillselectcatalog("getmetertype", "metertype", "metertypeid", "description", null);
controller:
[authorize] public string getactivemeter() { string toreturn = string.empty; var userid = user.identity.getuserid(); var currentuser = userclass.getuserbranchofficeid(userid); try { igenericrepository<meter> entity = new genericrepository<meter>(); igenericrepository<metertype> entity2 = new genericrepository<metertype>(); //there water value in column description var result = entity.getlist(x => x.status).where(x => x.branchofficeid == currentuser); toreturn = new javascriptserializer().serialize(result); } catch (exception ex) { throw ex; } return toreturn; }
"water"
value table called metertype
in column called description
regards
[authorize] public string getactivemeter() { string toreturn = string.empty; var userid = user.identity.getuserid(); var currentuser = userclass.getuserbranchofficeid(userid); try { igenericrepository<meter> entity = new genericrepository<meter>(); var result = entity .getlist(x=>x.state, x => x.metertype) .where(x=>x.branchofficeid==currentuser) .select(x=>new { id = x.id, meter1 = x.meter1 + ' - " + x.metertype.description}); toreturn = new javascriptserializer().serialize(result); } catch (exception ex) { throw ex; } return toreturn; }
Comments
Post a Comment