qq_29974795 2015-07-20 08:07 采纳率: 100%
浏览 3932
已采纳

jquery 数组 动态添加元素

 grid.set({        
            columns: [
                { type: "indexcolumn" },
                { field: "loginname", width: 120, headerAlign: "center", allowSort: true, header: "单位", editor: { type: "textbox", minValue: 0, maxValue: 200, value: 25} },
                { field: "age", width: 100, headerAlign: "center", allowSort: true, header: "年月", editor: { type: "textbox"} },
                { field: "remarks", width: 120, headerAlign: "center", allowSort: true, header: "姓名", editor: { type: "textbox"} }
            ]
        });

想向columns中动态添加元素,如何添加?

  • 写回答

3条回答 默认 最新

  • danielinbiti 2015-07-20 08:15
    关注

    关键是grid能不能把columns取出来,从set来看,columns是取不到的,自己可以该一下定义

     var colArr =  [
    { type: "indexcolumn" },
    { field: "loginname", width: 120, headerAlign: "center", allowSort: true, header: "单位", editor: { type: "textbox", minValue: 0, maxValue: 200, value: 25} },
    { field: "age", width: 100, headerAlign: "center", allowSort: true, header: "年月", editor: { type: "textbox"} },
    { field: "remarks", width: 120, headerAlign: "center", allowSort: true, header: "姓名", editor: { type: "textbox"} }
    ];
    grid.set({
    
    columns:colArr
    });
    这样可以通过
    colArr.push({type:"新的type"});
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办