title: Kendo Grid: Column Header Checkbox 'Check All' that checks boxes across grid all pages
body: <p>Is there an example out there in javascript and/or jquery where someone has a 'Check all' checkbox that checks all checkboxes across all pages of a grid?</p>
  
  <p>I have been trying for 3 days now and I am not finding a clean answer.</p>
  
  <p>What i have now is ugly and does not really work...</p>
  
  <pre><code>        function onRequestEnd(e) {
              var masterCbChecked = $("#masterCheckBox").is(':checked');
              var grid = $("#grid").data("kendoGrid");
  
              for (var i = 0; i &lt; grid.dataSource.total(); i ++) {
                  var dataRow = $("#grid").data("kendoGrid").dataSource.data()[i];
                  var elementRow = grid.table.find(".cbAdvisor")[i];
                  if (elementRow != null) {
                      var checked = elementRow.checked,
                          row = $(elementRow).closest("tr"),
                          dataItem = grid.dataItem(grid.tbody.find("tr").eq(i));
                      checkedIds[dataItem.DimAgentId] = masterCbChecked;
                      if (masterCbChecked) {
                          //-select the row
                          elementRow.checked = true;
                          row.addClass("k-state-selected");
                          dataRow.IsSelected = true;
                      } else {
                          //-remove selection
                          elementRow.checked = false;
                          row.removeClass("k-state-selected");
                          dataRow.IsSelected = false;
                      }
                  }
              }
  
          }
  
          function checkAll(ele) {
              var state = $(ele).is(':checked');
              var grid = $("#grid").data("kendoGrid");
              //grid.dataSource.pageSize(grid.dataSource.total());
              //grid.dataSource.read();
              //grid.refresh();
  
              var currentPage = $("#grid").data("kendoGrid").dataSource.page();
  
              checkedIds = {};
  
              //for (var a = 0; a &lt; modelJson.length; a ++) {
              //    var m = modelJson[a];
              //    m.IsSelected = true;
              //}
              for (var a = 1; a &lt; 2; a ++) {
                  var pager = grid.pager;
                  pager.bind('change', a);
                  grid.one("dataBound", function () {
                      this.dataSource.page(a);
                  });
                  grid.dataSource.fetch();
  
                  for (var i = 0; i &lt; grid.dataSource.total(); i ++) {
                      var dataRow = $("#grid").data("kendoGrid").dataSource.data()[i];
                      var elementRow = grid.table.find(".cbAdvisor")[i];
                      if (elementRow != null) {
                          var checked = elementRow.checked,
                              row = $(elementRow).closest("tr"),
                              dataItem = grid.dataItem(grid.tbody.find("tr").eq(i));
                          checkedIds[dataItem.DimAgentId] = state;
                          if (state) {
                              //-select the row
                              elementRow.checked = true;
                              row.addClass("k-state-selected");
                              dataRow.IsSelected = true;
                          } else {
                              //-remove selection
                              elementRow.checked = false;
                              row.removeClass("k-state-selected");
                              dataRow.IsSelected = false;
                          }
                      }
                  }
  
                  pager.bind('change', currentPage);
                  grid.one("dataBound", function () {
                      this.dataSource.page(currentPage);
                  });
                  grid.dataSource.fetch();
  
                  //mark for paging
                  if (dataRow != null) {
                      if (state) {
                          dataRow.IsSelected = true;
                      } else {
                          dataRow.IsSelected = false;
                      }
                  }
  
              };
  
              if (!state) {
                  checkedIds = {};
              }
  
              //grid.dataSource.pageSize(50);
              //grid.refresh();
          }
  </code></pre>