Forum



Hi
When create a table I want to dynamically create columns, depending on the structure of the database.
I write:
$(document).ready(function(){
names = [];
model = [];
$.getJSON("/jsonrpc/dispatcher.get_raion_names", {}, function(data) {
for (i=0; i<data.result.length; i++){
names[i] = data.result[i][0];
}
for (i=0; i<data.result.length; i++) {
model[i] = {name:data.result[i][0], index:data.result[i][1], width:80, align:'center', sortable:false};
}
console.info(names, model);
});
$("#jgrid_raions").jqGrid({
sortable: true,
url: '/dispatcher/json/get_raions',
datatype: 'json',
colNames: window.names,
colModel: window.model,
rowNum:15,
rowList:[15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40],
mtype: 'GET',
pager: $('#pager_raions'),
autowidth: true,
//width: window.width-1,
rownumbers: true,
sortname: '#',
sortorder: "desc",
height: "100%",
caption: '',
viewrecords: true,
toolbar : [true,"top"],
altRows : true,
//hoverrows: true,
//toolbar : [true,"bottom"],
//shrinkToFit :false,
//rownumbers: true,
//rownumWidth: 40,
gridview: false,
loadui: 'disable',
});
$("#t_jgrid_raions").height(25).jqGrid('filterGrid',"jgrid_raions",{
gridModel:true,
gridToolbar:true,
enableSearch: false,
enableClear: false,
autosearch: false
}).css("display", "none");
$("#jgrid_raions").jqGrid('navGrid','#pager_raions',
{edit:false,add:false,del:false,search:false,refresh:false },
{}, // edit options
{}, // add options
{}, //del options
{multipleSearch:true} // search options
);
FireBug write:
names = ["Ðмерика", "Ðфрика"]
model = [Object { name="Ðмерика", more...}, Object { name="Ðфрика", more...}]
but grid not work..
p.s. sorry for my english..
13:56

10/08/2009

You can remove old jqGrid with respect of jQuery.remove(). jqGrid create some additional dives over the table element and the pager div. So if your table has id="list" you should remove div with the id="gbox_list". It contains all other dives. After calling of jQuery.remove() you will have no more table and pager dive, so you have to insert there also dynamically for example with jQuery.after() method. To do this you have to have on the html page an anchor (an element with known id) which you will use in the jQuery.after() method.
Alternatively you can place the table element and the pager div inside another div and call jQuery.empty() and jQuery.html() methods with the id of this parent div to remove and to insert the jqGrid dynamically.
Most Users Ever Online: 715
Currently Online:
65 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66