JQuery JTable fill table with records from ajax call -


i fill jtable records ajax call. records in json format, this:

{  "result":"ok",    "records":[     {"personid":1,"name":"benjamin button","age":17,"recorddate":"\/date(1320259705710)\/"},     {"personid":2,"name":"douglas adams","age":42,"recorddate":"\/date(1320259705710)\/"},     {"personid":3,"name":"isaac asimov","age":26,"recorddate":"\/date(1320259705710)\/"},     {"personid":4,"name":"thomas more","age":65,"recorddate":"\/date(1320259705710)\/"}    ] } 

function makes call:

 $("#btnsearchoffer").click(function () {      $.ajax({       method: 'post',       url: '/salesofferinvoicedeliverynote/searchoffers/',       data: {         corac_num: $("#inputorac_num").val(),         corac_dat_from: $("#inputorac_dat_from").val(),         corac_dat_to: $("#inputorac_dat_to").val(),         corac_sta: $("#selectorac_sta option:selected").val(),         iacco_key: $("#hiddenacco_key").val(),         iuser_key: $("#hiddenuser_key").val()               },       success: function (response) {          if (response.result === "ok") {           //here fill jtable data (what i've tried here            //it's not working):           $('#tbloffers').jtable().listaction = response;         }       },       error: function (response) {         alert(response);       }     });    }); 

i need fill jtable button press, because of parameters text fields needs included in ajax call:

table looks this:

 $('#tbloffers').jtable({     title: 'pregled ponudb',     paging: true,     pagesize: 20,     sorting: true,     defaultsorting: 'corac_num desc',     actions: {       listaction: "/salesofferinvoicedeliverynote/searchoffers/"     },     messages: {       servercommunicationerror: 'napaka!',       loadingmessage: 'nalagam...',       nodataavailable: 'ni podatkov!'     },     fields: {       corac_num: {         key: true,                 title: 'Št. ponudbe'       },       corac_dat: {         title: 'datum'       },       cacco_nme: {         title: 'kupec'       },       orac_gro_sum: {         title: 'za plačilo'       }     }   }); 

by using load method can send data listaction. following example(asp.net web form c#) code.

client side:

//re-load records when user click 'search offer' button. $('#btnsearchoffer').click(function (e) {     e.preventdefault();     $('#tbloffers').jtable('load', {         corac_num: $("#inputorac_num").val(),         corac_dat_from: $("#inputorac_dat_from").val()     }); }); 

and in server side can receive data:

[webmethod(enablesession = true)] public static object searchoffers(string corac_num, int corac_dat_from, int jtstartindex, int jtpagesize, string jtsorting) {     //handle null parameters } 

i have not added parameters. hope understand code. let me know if need help.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -