ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: bsolteam on June 19, 2014, 08:27:51 pm
-
Hi,
Is there any demo or Api for adding column dynamically. Because i didn't find any thing for adding column dynamically. I need to add a column dynamically like, same way we are using in dynamic row adding.
Thanks in advance.
-
colModel is an array of columns.
Add the column to colModel the way you do array manipulation in javascript.
call refresh after it.
-
I am trying to add colums dynamically (I have some nested ones) and it doesn't seems to be working.
What I am doing wrong?
function addWklyOtWO() {
var woItm = {title:"<b>2</b>", minWidth:50, dataIndx: "num2", resizable: false, align:"center",
colModel:[
{title:"<b>WO#</b>", minWidth:100, dataIndx: "woNo2", resizable: false, align:"center", cls:'Start-DayBorder',hidden:true},
{title:"<b>Units</b>", minWidth:40, dataIndx: "unts2", resizable: false, align:"center",hidden:true},
{title:"<b>Task#</b>", minWidth:40, dataIndx: "tsk2", resizable: false, align:"center",hidden:true},
{title:"<b>Ord Hrs</b>", minWidth:40, dataIndx: "ord_hrs2", resizable: false, align:"center",hidden:true},
{title:"<b>Veh</b>", minWidth:40, dataIndx: "veh2", resizable: false, align:"center",hidden:true},
{title:"<b>Veh Hrs</b>", minWidth:40, dataIndx: "veh_hrs2", resizable: false, align:"center",hidden:true},
{title:"",dataIndx:"vcRecId2",hidden:true},
{title:"",dataIndx:"lcRecId2",hidden:true}
]};
var otColMdl = $("#grid_wkly_ot").pqGrid("option", "colModel"),
woColMdl = otColMdl[0].colModel;
woColMdl.push(woItm);
$("#grid_wkly_ot").pqGrid("option", "colModel", otColMdl);
$("#grid_wkly_ot").pqGrid("refresh");
}
-
Put a breakpoint in the function and check the value of otColMdl before updating colModel.
-
I do see everything fine in both woColMdl and otColMdl.
Maybe the problem with the nested columns?
-
Got it work. It is related to the nested columns
I added one line after the push:
woColMdl.push(woItm);
otColMdl[0].colModel = woColMdl;
and everything is working.
Thanks a lot.