2013-08-05 37 views
8

我們正在使用Kendo網格。我在我的cshtml文件和我的js文件中創建了一個表,我將它綁定到數據。我的問題在於網格分頁不會消失。我需要頁面上的所有項目,因爲我們不期望有太多的負載。我嘗試刪除可分頁的屬性,我試圖標記pageable: false。但我仍然看到網格在一個頁面中只顯示10個項目並給出分頁。如何在kendogrid上禁用分頁

通過使用this.pager.element.hide(),我們可以隱藏尋呼機,但這並不能解決目的,因爲尋呼機是隱藏的,但分頁仍在完成。所以,現在,從第11個元素開始的元素位於該頁面的頁面上,但我們無法導航到它。

這裏是現有的代碼。我已經刪除了表中不相關的列。 .CSHTML文件:

<table style="width: 100%;" class='list-entity' id='inboxItems'> 
       <thead> 
        <tr> 
         <th data-field='Actions' class="iconCell" style='width: 1%'>&nbsp;</th> 
         <### THERE ARE MORE COLUMNS HERE AND THOSE HAVE CORRESPONDING COLUMNS IN SETTINGS ###>  
        </tr> 
       </thead> 
      </table> 

JS文件:

var settings = { 
     kendosettings: { 
      dataSource: { 
       data: requestItemsList, 
       schema: { 
        // required if get method will be used 
        model: { 
         id: "StepApproverKey" 
        } 
       }, 
       group: [ 
        { 
         field: "GroupByAttribute", 
         dir: "asc", 
         aggregates: 
         [ 
          { field: "GroupByAttribute", aggregate: "count" }] 
        }] 
      }, 
      sort: { field: "SubmittedOn", dir: "desc" }, 
      sortable: true, 
      pageable: false, 
      scrollable: false, 
      columns: [ 
       { 
        field: "Actions", 
        title: "Actions", 
        template: kendo.template($("#inboxrowEditTemplate").html()) 
       }, 
       { field: "StepApproverKey", hidden: true }, 
       { 
        field: "GroupByAttribute", 
        hidden: true, 
        groupHeaderTemplate: kendo.template($("#inboxrowgroupHeaderTemplate").html()), 
        headerAttributes: { 
         style: "width: 100%" 
        } 
       } 
      ], 
      selectable: "row", 
     } 
    }; 
    $('#inboxItems').pdi().displaygrid(settings); 
+0

你有沒有嘗試設置滾動爲真? – rafoo

+0

是的。試過Scrollable True和False。我仍然看到分頁發生。 – Feroz

回答

6

我張貼這對劍道論壇,似乎我們能夠解決的唯一方法是動態地設置網格的頁面大小,然後隱藏尋呼機。在我們的例子中,因爲我們希望所有項目都是單一負載,我們將其設置爲發送給客戶端的列表長度。以下是我使用的代碼,它正在工作。

var inboxGrid = $('#inboxItems').data("kendoGrid"); 
inboxGrid.dataSource.pageSize(<NUMBER OF ITEMS IN THE LIST>); 
inboxGrid.refresh(); 
inboxGrid.bind("dataBound", function() { 
       this.pager.element.hide(); 
     }); 
+0

我發現了Kendo的論壇convo - http://www.telerik.com/forums/how-to-disable-paging-on-a-kendogrid – vapcguy

+1

<應該寫的清單中的項目數量> inboxGrid.dataSource .total()'。 – vapcguy

0

使用:

inboxGrid.bind("dataBound", function() { 
      this.pager.element.hide(); 
    }); 

並沒有爲我工作。也許是因爲我使用Razor和MVC來顯示網格,或者因爲我們使用Bootstrap作爲CSS,我不知道。但讓我這樣做,反而:

var inboxGrid = $('#inboxItems').data("kendoGrid"); 
inboxGrid.dataSource.pageSize(inboxGrid.dataSource.total()); 
inboxGrid.refresh(); 
$('[class*="k-pager-nav"]').hide();