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
Cellattr and font-style
24/01/2013
23:11
Avatar
Azerty
Member
Members
Forum Posts: 4
Member Since:
26/12/2012
sp_UserOfflineSmall Offline

Hello,

i found what i think is a bug, i am able to set any style parameter in the cell attr function except font-style.

I fixed it on my side writing acp = celp.split("style="); instead of acp = celp.split("style"); in formatCol function of jqGrid.

Thanks

25/01/2013
13:57
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

I think that it would be better to rewrite the code which parse cellattr and use

/^\s*(\w+)\s*=\s*([\"|\'])(.*?)\2(.*)/.exec(...)

to parce the results returned from cellattr callback. If one use

var attrStr = cm.cellattr.call(...), matches, name, value, quote, tilteValue, classes = "";
if (attrStr && typeof attrStr === "string") {
    // ??? probably one can create object with properties from the attrStr
    // and then to use one common function with constructTr to combin the default
    // properties with the properties used in cellattr and rowattr.
    // Probably one could use $.extend with the most attributes. The exception are
    // only class and style attributes which hold multi-values with " " or ";" as separator
    while (true) {
        // we have to use ? in the construction ([^\2]*?) to have non-greedy (lazy, minimal) matching
        // so that we will find the FIRST closing quote instead of default the LAST matching.
        matches = /^\s*(\w+)\s*=\s*([\"|\'])(.*?)\2(.*)/.exec(attrStr);
        if (matches === null || matches.length < 5) {
            ... // need nothing to done one need use styleValue, classes and tilteValue
                // to generate the results
        }
        name = matches[1].toLowerCase();
        quote = matches[2]; // one should better use the character to quote the value matches[3]
        value = matches[3];
        attrStr = matches[4];
        switch (name) {
            case "class":
                // if some spetial characters are inside of class value there MUST be escaped
                // so we can use any quote characters (' or ") around the call value.
                // So we don't need to save quote used in class attribute
                if (classes) {
                    classes += " " + value;
                } else {
                    classes = value;
                }
                break;
            case "title":
                tilteValue = value;
                break;
            case "style":
                styleValue += value;
                break;
            default:
                rest += " " + matches[1] + "=" + quote + value + quote;
                break;
        }
    }
}

It's just an example how the code looks like.

Regards
Oleg 

Forum Timezone: Europe/Sofia

Most Users Ever Online: 496

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