kendoUI下拉框


kendoUI下拉框之固定值选项:
在$("#demo_grid").kendoGrid的columns中设置属性“isEnable”是固定值为“Yes”/“No”的下拉列表:
    {
field: "isEnable", 
    /*title: "<fmt:messagekey="p.message.isEnable"/>",此处标题设置国际化*/
title: "isEnable",
    attributes: {style: "font-size: 15px"},
    template: function(dataItem) {
    var value = dataItem.isEnable;
    if(value === "Y"){
    return "Yes";
    }else if(value === "N"){
    return "No";
    }else{
    return "";
    }
    },
    editor: function(container,options){
    $('<input name="'+options.field+'"/>')
    .appendTo(container)
    .kendoDropDownList({
    dataTextField: "is_enableText",
    dataValueField: "is_enableValue",
    valuePrimitive: true,
    dataSource: [
                   {is_enableText: "Yes", is_enableValue: "Y"},
                   {is_enableText: "No", is_enableValue: "N" }
               ]
    });
    }
    }


kendoUI下拉框之获取值选项及如何设置kendoUI下拉框中的默认值:
同样的,在$("#demo_grid").kendoGrid的columns中设置属性“Rate”的值来自后台url"/getRate"(此链接返回的是一个对象列表,以对象的形式将属性“Rate”值封装起来传输过来)中数据的下拉列表:
{
  field: "Rate", title: "rate", attributes: {style: "font-size: 15px"}, width:"115px", template: function(dataItem) {
    if(dataItem != null){
    return dataItem.tier1RatePlan;
    }
    },
    editor: function(container,options){
    $('<input name="'+options.field+'"/>')
    .appendTo(container)
    .kendoDropDownList({
    dataTextField: "ratePlan",
    dataValueField: "ratePlan",//ratePlan:对应此“/getRate”返回对象的一个属性名
    valuePrimitive: true,
    autoBind:true,
    dataSource: {
            transport: {
                   read: "/getPlan",
                   dataType: "json"
                       }
               },
                  //添加的时候下拉表默认选择一个
                    dataBound: function(e){
                   if (this.select() === -1) { //check whether any item is selected
                       this.select(0);
                       this.trigger("change");//真实有效的获取到这个值(而非仅仅显示出来)
                     }
                  }   
    });
      }
    },


在schema之前可通过添加requestStart或requestEnd来控制在执行每个operation("read"/"create"/"update"/"destroy"...)之前或之后做点什么。例如,在执行非read操作结束时,demoGrid中的数据进行一次read操作即每进行一次操作之后都read重新读取一遍(等于是刷新一遍):
   requestEnd: function(e){
if(e.type != "read"){
     demoGrid.data("kendoGrid").dataSource.read(); 

},  
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值