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中动态添加元素,如何添加?

关键是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"});

temp = [];
$('a').click(function (){
var txt = $(this).text();
if(!$.inArray(txt, temp)) {
temp.push(txt);
} else {
temp = $.grep(temp, function(n,i){
return n != txt;
});
}
});

你的grid是什么对象?自己看api罗。。如果提供了你这种方法,你自己看参数是什么,set是干什么用的