kendoGrid的一些基礎配置


$("#grid").kendoGrid({
        dataSource:{
            transport: {
                read:  {
                    url: crudServiceBaseUrl + "/Products",
                    dataType: "jsonp"
                },
                update: {
                    url: crudServiceBaseUrl + "/Products/Update",
                    dataType: "jsonp"
                },
                destroy: {
                    url: crudServiceBaseUrl + "/Products/Destroy",
                    dataType: "jsonp"
                },
                create: {
                    url: crudServiceBaseUrl + "/Products/Create",
                    dataType: "jsonp"
                },
                parameterMap: function(options, operation) {
                    if (operation !== "read" && options.models) {
                        return {models: kendo.stringify(options.models)};
                    }
                }
            },
            schema:{
                model:{
                    id:'id',
                    fields:{ }
                }
            },
            pageSize:20,
            batch: true,
            serverPaging: true,
            serverFiltering: true,
            serverSorting: true
        },
        // 導出excel
        toolbar:['excel','create'],
        persistSelection:true,          //checkbox多選的時候,必須添加,否則獲取不到選中的數據
        noRecords:true,                 //當表格中沒有數據,顯示的信息
        excel:{
            fileName:'input.xlsx',      
            filterable:true ,  //顯示過濾
            allPages: true    //導出所有頁的數據
        },
        editable: {
            createAt: "bottom"     //每次新增的時候,從底部新增  bottom/top
        },
        pageable: {
            pageSizes: true,
            buttonCount: 5,
            refresh: true          //刷新按鈕
        },
        columns:[
            { 
                field:'b',           //返回數據字段
                title:'物料名稱',      
                locked:true,         //凍結列
                filterable:{ 
                    cell:{ 
                        operator:'contains',                     //包含
                        suggestionOperator:'contains',           //顯示查詢出來的數據   
                        showOperators:false                      //去掉右側過濾按鈕
                    }
                }, 
                attributes: {
                    "class": "table-cell",                               //添加類名
                    style: "text-align: right; font-size: 14px"          //添加樣式
                },
                template:'',                                            //模板
                width:200
            },
            {   
                title:'操作',
                // 按鈕,控制是否顯示
                command:[{ name: "destroy", visible: function(dataItem) { return !dataItem.isDisabled === true }}]
            },
{ title:
'行號', template:'#= ++record #', width:50, attributes: { style: "text-align: center;"} }, // checkbox框 { selectable:true, width:50 }, ], dataBinding:function(){ // 顯示行號,必須要有pageSize record = (this.dataSource.page() - 1) * this.dataSource.pageSize(); } })

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM