2014-05-10 139 views
1

KendoUI電網頁腳演員我也正從我的PHP腳本返回以下JSON來填充我的劍道格:從返回的JSON

data: [{id:1, sku:-, theName:Two tier wedding veil, basePrice:77.00, dimensions:-, weight:-,…},…] 
querytime: "0.0000" 
rowcount: 4 

偉大的工程。正如你所看到的,我添加了一個名爲「querytime」的額外參數。

如何訪問JS端的東西,以便我可以將它附加到網格的頁腳?

我曾嘗試:

console.log($('#productGrid').data("kendoGrid").dataSource); 

,試圖找到我的額外參數所在的位置信息,但無濟於事。

如何訪問我的客戶參數?


var columns = [ 
    { 
     field: 'dateRaw', 
     title: 'Date added', 
     width: '90px', 
     template: '<span class="data" data-menu-id="1" data-item-id="#=id#" data-item-type="products"><abbr title="At #=time#">#=dateFormatted#</abbr></span>' 
    }, 
    { 
     field: 'sku', 
     title: 'SKU', 
     width: '120px' 
    }, 
    { 
     field: 'theName', 
     title: 'Name' 
    }, 
    { 
     field: 'dimensions', 
     title: 'Dimensions', 
//width: '120px' 
    }, 
    { 
     field: 'weight', 
     title: 'Weight', 
     width: '80px' 
    }, 
    { 
     field: 'basePrice', 
     title: 'Price', 
     width: '60px', 
     format: '{0:n}' 
    }] 

$('#productGrid').kendoGrid({ 
    rowTemplate: '', 
    dataSource: { 
     transport: { 
      read: { 
       type: 'POST', 
       dataType: 'json', 
       url: 'Ajax', 
       data: { 
        call: 'Product->productGrid' 
       } 
      } 
     }, 
     schema: { 
      data: 'data', 
      querytime: 'querytime', 
      total: 'rowcount', 
      model: { 
       id: 'id', 
       fields: { 
        dateRaw: { 
         type: 'date' 
        }, 
        id: { 
         type: 'number' 
        }, 
        sku: { 
         type: 'string' 
        }, 
        basePrice: { 
         type: 'number' 
        } 
       } 
      } 
     }, 
     pageSize: 20, 
     serverPaging: true, 
     serverFiltering: true, 
     serverSorting: true, 
     error: function(e) { 
      modalError(e.errorThrown + "<br/>" + e.status + "<br/>" + e.xhr.responseText) 
     } 
    }, 
    height: 700, 
    autoBind: false, 
    filterable: true, 
    sortable: true, 
    pageable: true, 
    columns: columns 
}) 

回答

0

你是相當接近: querytime可以在您的數據源的選擇對象中:

$('#productGrid').data('kendoGrid').dataSource.options.querytime 
+0

當我CONSOLE.LOG,我不能看到我的自定義參數的任何地方:( – imperium2335

+0

你如何初始化你的kendogrid? –

+0

請看我的編輯 – imperium2335