Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
Dynamic colName & colModel
07/07/2010
12:17
Avatar
Gordon
New Member
Members
Forum Posts: 2
Member Since:
26/04/2010
sp_UserOfflineSmall Offline

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..

07/07/2010
13:56
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

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. 

12/07/2010
01:54
Avatar
Gordon
New Member
Members
Forum Posts: 2
Member Since:
26/04/2010
sp_UserOfflineSmall Offline

ok, I understand ..
A regular means it can be done?

..means in jqgrid.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 496

Currently Online:
34 Guest(s)

Currently Browsing this Page:
1 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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information