telerik - Kendo Grid doesn't send all checked items -


i have kendo grid has checked box items. want check items , send them controller, export checked data pdf. but, when have checked items, kendo grid sends checked items first page of grid, , report in pdf has 1 page. how checked items kendo grid? code here:

<div style="text-align:right; font-size: 0.9em;height:28px;position: relative;">          <span style="float:left;text-align:left;">             <a href="#" onclick="checkall();">check all</a>&nbsp;             <a href="#" onclick="uncheckall();">uncheck all</a>&nbsp;             <a class="k-button k-button-icontext k-grid-patient" id="hrefcheckedpatients" href="#" onclick="getchecked();">export pdf</a>&nbsp;             <a href="#" id="lnkpdfdownload" style="display:none;" onclick="$(this).hide();">download generated pdf</a>             <label id="checkedmsg" style="color:red;display:none;"></label>         </span> (html.kendo().grid<runsummary>()           .name("checkedpatients")                     .datasource(datasource => datasource                 .ajax().pagesize(25)                         .sort(sort => sort.add("uniqueid").ascending())                                         .read(read => read.action("getrunsummaries", "patientreport")))           .columns(columns =>               {                    columns.bound(c => c.uniqueid).title(elsoregistry.resources.views.home.homestrings.uniqueid)                         .clienttemplate("<input type='checkbox'  class='primarybox' id='#= uniqueid #'>#= uniqueid #</input>");                   columns.bound(c => c.runno).title(sharedstrings.run);                   columns.bound(c => c.birthdate).title(sharedstrings.birthdate).format("{0:g}").filterable(true);                    columns.bound(c => c.customage).title(sharedstrings.age)                          .filterable(                              filterable => filterable                                  .ui("agefilter")                                  .extra(false)                                  .operators(operators => operators                                      .forstring(str => str.clear().isequalto("is equal to"))                                      )                         );                    columns.bound(c => c.timeon).title(patientstrings.dateon)                       .format("{0:g}")                       .filterable(true);                   columns.bound(c => c.timeoff).title(patientstrings.dateoff)                       .format("{0:g}")                       .filterable(true);                   columns.bound(c => c.dischargedalive).title(patientstrings.dischargedalive).filterable(true).clienttemplate("#= dischargedalive ? 'yes' : 'no' #");                   columns.bound(c => c.showsubmitted).title(patientstrings.submitted).filterable(true).clienttemplate("#= showsubmitted ? 'yes' : 'no' #");                   columns.bound(c => c.supporttypeenum).title(patientstrings.supporttype).filterable(true);//.clienttemplate("#= supporttype ? 'yes' : 'no' #");               }           )           .pageable(p => p.pagesizes(new[] {10, 25, 50, 100}))           .sortable()           .filterable( )           .events( e => e.filtermenuinit("filtermenufuncwithage") ) // apply x [closing box] on pop filter box           )  function getchecked() {         $('#checkedmsg').text('');                 var ids = new array();          $('.primarybox:checked').map(function (index) {             ids.push(this.id);         });                  if (ids.length == 0) {             $('#checkedmsg').text('@elsoregistry.resources.views.patient.patientstrings.nopatientsselected').show();             $('#hrefcheckedpatients').blur();             return;         } else {             $('#checkedmsg').text('').hide();             $('#hrefcheckedpatients').blur();          }          $.ajax({             type: "post",             url: "/patientreport/exporttopdf",             datatype: "json",             traditional: true,             data: { uniqueids: ids },             success: function (data) {                 if (data.success) {                                         $('#lnkpdfdownload').show();                     $('#lnkpdfdownload').attr('href', '/patientreport/downloadfile' + '?fname=' + data.fname);                 } else {                     $('#lnkpdfdownload').hide();                 }              },             error: function (jqxhr, textstatus, errorthrown) {                 $('#checkedmsg').text('@elsoregistry.resources.views.patient.patientstrings.checkederror').show();                 $('#hrefcheckedpatients').blur();             }         });         } </script> 

thank in advance help.

we can't directly ids kendo grid pages. have manually pages.

please try below code snippet.

<script>      var ids = [];      function checkall() {         var datasource = $("#checkedpatients").data("kendogrid").datasource;         var filters = datasource.filter();         var totalrowcount = parseint(datasource.total().tostring());         var totalpages = math.ceil(totalrowcount / datasource.pagesize());         var currentpagesize = $("#checkedpatients").data("kendogrid").datasource.page();         pagetraverser(datasource, 1, totalpages,filters, function () {             $("#checkedpatients").data("kendogrid").datasource.page(currentpagesize);             alert("you have slected ids:- " + ids.join(','));         });     }      function pagetraverser(datasource, targetpage, totalpages,filters, completionfunction) {          datasource.query({             page: targetpage,             filter: filters             pagesize: 1,         }).then(function () {             var view = datasource.view();             (var viewitemid = 0; viewitemid < view.length; viewitemid++) {                 var viewitem = view[viewitemid];                 ids.push(viewitem.uniqueid); //please change field name here             }             targetpage++;             if (targetpage <= totalpages) {                 pagetraverser(datasource, targetpage, totalpages, filters, completionfunction);             } else {                 completionfunction();             }         });     }  </script> 

let me know if concern.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -