Grid常见操作

 grid = $("#grid").data("kendoGrid"); //获取kendoGrid对象
   for (var i = 0; i < grid.columns.length; i++) { //遍历所有字段
                if (grid.columns[i].field != null) {
                    var columnInfo = {};
                    columnInfo["name"] = grid.columns[i].field; //获取字段name
                    columnInfo["title"] = grid.columns[i].title; //获取字段实际显示标题
                    columnInfo["width"] = grid.columns[i].width; //获取字段显示宽度
       editable: false,//grid不可编辑
        autoBind: false,//grid不自动加载
//grid某列不可编辑
 fields: {
                    customerCode:{
                        editable:false,
                        type:"string",
                    },
           }
//grid某个字段为必输
 fields: {
   description:{
                        validation: {
                            required: true
                        },
                    },
        }
 /*隐藏列customerId*/
    var grid = $("#grid").data("kendoGrid");
    grid.hideColumn("customerId");
//grid点击事件
  $(grid).on("click", "td", function (e) {
      var rowIndex = $(this).parent().index();
      var contactData = $("#grid").data("kendoGrid").dataSource.data();
      otviewModel.model.set("trxSummaryId",contactData[rowIndex].trxSummaryId);//获取所点击字段
      $('#outstorageTrxGrid').data('kendoGrid').dataSource.page(1);//grid刷新
  })
//grid字段改变事件,但里面内容改变时,触发change
{
                field: "price",
                title: '<@spring.message "product.price"/>',
                width: 120,
                editor: function (container, options) {
                    $('').appendTo(container).kendoNumericTextBox({
                        min: 0,
                        change: function () {
                            if(options.model.get("manDay")>0&options.model.get("price")>0) {
                                options.model.set('totalPrice', options.model.get("manDay")*options.model.get("price"));
                            }else {
                                options.model.set('totalPrice',0);
                            }
                        }
                    });
                },
            },

                    
                    

你可能感兴趣的:(Grid常见操作)