1

I have a requirement where i need to dynamically increase or decrease Jqgrid column .I have multiple buttons like One,Three,Seven,One Month etc.These buttons denotes days and same i need to add as column names in Jqgrid dynamically.

Here is the pic of the design..

Design layout

Now as per the picture ,if i click on current only one column should be visible ,if click on One Day two columns should be visible and similarly if click on Month thirty columns should be dynamically generated.

Here is my JQgrid sample code that i am referring..

                grid.jqGrid({
                datatype: "local",
                data: mydata,
                colNames:['Room No', '12', '13','14','15','16'],
                colModel:[
                    {name:'Room No',index:'Room No', width:42, align:'center'},
                    {name:'',index:'', editable:true, align:'center'},
                    {name:'',index:'', editable:true, align:'center'},
                    {name:'',index:'', editable:true,align:'center'},
                    {name:'',index:'', editable:true,align:'center'},
                    {name:'',index:'', sortable:false,align:'center'}
                ],

Please help me..

user3617097
  • 115
  • 1
  • 2
  • 10

1 Answers1

2

A little search and I found this topic explaining how to do what you want. And here is a demo adding columns dinamically. Basically, what you have to do is: create a function with the data you want for each of your tabs and insert a click event handler to unload the previous set data and call the function for the specific clicked tab to insert new data in the grid.

Community
  • 1
  • 1
lucasdc
  • 1,032
  • 2
  • 20
  • 42