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
Seleting the checkbox based on XML value
24/01/2013
22:23
Avatar
aram535
Member
Members
Forum Posts: 6
Member Since:
24/01/2013
sp_UserOfflineSmall Offline

Hi,

I have the following XML (which can be chaged)being used to popuilate jqGrid 4.4.1:

<rows>

 <row><id>1</id><host>123</host><checked>1</checked>....</row>

 <row><id>2</id><host>456</host><checked>0</checked>....</row>

</rows>

I would like my grid to have the checkbox for row #1 checked. 

    var grid = $("#grid11");
...
    grid.jqGrid({
        url: 'listHostsXML.php?id='+id,
        datatype: 'xml',
        caption: "Hosts",
        mtype: 'post',
        height: 'auto',
        hidegrid: false,
        loadonce: true,
        autowidth: true,
        viewrecords: true,
        multiselect: true,
        rownumbers: true,
        rowNum: -1,
        edit:false,
        add:false,
        del:false,
        colNames: ['Id','Host',....],
        colModel: [{ ... }]
});
28/01/2013
16:06
Avatar
aram535
Member
Members
Forum Posts: 6
Member Since:
24/01/2013
sp_UserOfflineSmall Offline

Can I assume this is not possible?

29/01/2013
10:37
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Can I assume you have not read the docs?

Please look for using formatters in jqGrid.

Rgerads

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

29/01/2013
11:40
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Hi Tony,

I think that the user want to set multilelect chechbox based on <checked> from the data. One can't define currently any formatter options or some other options for multilelect chechbox ("cb" column) so that the values of the checkbox were set based on the data. So one will have to use the method like setSelection sequencially inside of loadComplete to check the checkboxes. After every setting of checkbox the reflow of the page will take place, so all will be slowly as it could be.

It would be interesting to be able to assign the the value of the chechbox based on the input data or some callback (see the last parameter of addMulti in the line and in the line). If the option deselectAfterSort set to false one can do some triks to fill the chechboxes based on prefilled selarrrow (see the lines of code). One could fill selarrrow for example inside of beforeProcessing. In case of usage datatype: "xml"  the corresponding code fragment is missing in addXmlData.

Probably it would be nice to introduce some additional possibilities for developers to control of predefined "cb", "nm" and "subgrid" columns of grid.

Best regards
Oleg 

29/01/2013
12:14
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello Oleg,

Thank you for the explanation.

Just I have added onInitGrid event which raises only once before populating the data.

In this event a setColProperties can be used applied for the cb field like this

…jqGrid({

onInitGrid : function() {

    (this).setColProperty('cb' { attr : function(...){..} });

}

});

Hope this make sence since it can be used for other predefined columns.

Thanks

Regards

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

29/01/2013
19:31
Avatar
aram535
Member
Members
Forum Posts: 6
Member Since:
24/01/2013
sp_UserOfflineSmall Offline

Yes that should cover all of it.  Thank you.

30/01/2013
17:30
Avatar
aram535
Member
Members
Forum Posts: 6
Member Since:
24/01/2013
sp_UserOfflineSmall Offline

Quick question, according to firebug (this) or the grid variable don't have a setColProperty() method associated with them.  Am I assuming the wrong information?

I'm using the latest git (master) compiled locally.

30/01/2013
19:22
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

I find introduction of onInitGrid callback very helpful, but not in you case aram535. What Tony wrote is not exact code. It should be interpreted something like

onInitGrid: function() {
    $(this).jqGrid("setColProp", "cb", {
        cellattr: function (rowId, val, rawObject) {
            ...
        }
    });

The problem is that it helps not to set value of multilect checkbox because the checkbox is control inside of the cell and cellattr allows to set only attributes of the cell (<td> element) itself.

Like I wrote before the part of the code of addJSONData contains some parts of code which can set values of the multilect checkboxes based on the selarrrow array, but the code works only with datatype: "local".

So still don't see any elegant way to load information which multilect checkbox should be loaded. One can implement the selection using loop though data inside of loadComplete and usage of setSelection sequencially, but such solution will be not so quickly as it could be.

Best regards
Oleg

31/01/2013
10:57
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

@aram535 , sorry for mistake. It was may error.

The setColProperty does not exists. It should be setColProp instead - as Oleg write.

I'm sorry again, but I think Oleg is right. Will see what I can do.

Regards

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
46 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