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_TopicIcon
Add a class to a row during Json generation
07/01/2010
16:08
Avatar
kamass
Guest
Guests

Hi,

I would like to know if it's possible to add a class to a row during Json generation ?

Thus, I would be able to color rows thanks to css depending row values.

[Example]

    $response->rows[$i]['id']=$row['id'];
    $response->rows[$i]['clazz']='myCssClass';
    $response->rows[$i]['cell'] = array([...]);

Thanks.

07/01/2010
21:13
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Not possible for now. When using the readers with repeatitems set to false, this can be done easy, but will make a lot of code when this option is set to true.

Regards

Tony

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.

08/01/2010
12:09
Avatar
kamass
Guest
Guests

Hi,

I just want to say that I manage to do what I want by editing your JavaScript.

In grid.base.js :

Line 611 : (for Json)

- rowData[ari++] = "<tr id=\\""+ idr +"\\" role=\\"row\\" class= \\"ui-widget-content jqgrow ui-row-"+ts.p.direction+""+cn1+"\\">";

+ rowData[ari++] = "<tr id=\\""+ idr +"\\" role=\\"row\\" class= \\"ui-widget-content jqgrow ui-row-"+ts.p.direction+""+cn1+" " +cur["clazz"]+"\\">";

======================================

I haven't tried what is below, because I do not use Xml format.

Line 475-->484 : (for Xml)

            if( (idn+"").indexOf("[") === -1 ) {
                if (f.length) {
                    getId = function( trow, k) {return $(idn,trow).text() || k;
                    getClazz = function( trow, k) {return $("clazz",trow).text() || k;};
                } else {
                    getId = function( trow, k) {return $(ts.p.xmlReader.cell,trow).eq(idn).text() || k;
                    getClazz = function( trow, k) {return $(ts.p.xmlReader.cell,trow).eq("clazz").text() || k;};
                }
            }
            else {
                getId = function( trow, k) {return trow.getAttribute(idn.replace(/[\\[\\]]/g,"")) || k;
                getClazz = function( trow, k) {return trow.getAttribute("clazz".replace(/[\\[\\]]/g,"")) || k;};
            }

Line 496-->498 :

                rid = getId(xmlr,br+j);
                rclazz = getClazz(xmlr,br+j);
                cn1 = j%2 == 1 ? cn : '';
                rowData[ari++] = "<tr id=\\""+rid+"\\" role=\\"row\\" class =\\"ui-widget-content jqgrow ui-row-"+ts.p.direction+""+cn1+" "+rclazz +"\\">";

08/01/2010
12:20
Avatar
kamass
Guest
Guests

I just hope that you'll implement this feature in the next versions of jqGrid! Smile

I think it can be useful to a lot of people.

But your grid is already excellent, so... thank you for everything!

08/01/2010
12:30
Avatar
kamass
Guest
Guests

Here is the Css I have used (if people are interessed) :

tr.myCssClass td{
    background-color: #F2A22F;
    border-right: 1px solid #ddd;
    border-bottom: 1px solid #f3f3f3;
}

08/01/2010
13:52
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Thanks. Will try to investigate this and if everthing is ok will implement it - but remember I do not promiese this.

Best Regards

Tony

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.

08/01/2010
14:00
Avatar
kamass
Guest
Guests

It is normal, and I understand you don't have time to do everything people would like! Wink

Anyway thanks again for your support.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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