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
How to add color in a select field ?
15/03/2010
16:42
Avatar
phicarre
Member
Members
Forum Posts: 132
Member Since:
09/11/2009
sp_UserOfflineSmall Offline

A php script buids a list and the grid uses it like this:

var items= $.ajax(
    {
        url:'listofitems.php',
        async:false
    }).responseText;

The returned string has this structure:

"item1:item1;item2:item2;…itemn:itemn"

The column is defined like this:

{
        name:'reference',
        index:'reference',
        edittype:'select',
        editoptions:{value:items},
        editable:true 

 },

When the edit form is displayed I would like to see, for example, the odd items in red, the other ones in blue.

1) is it possible to "integrate" the color or the criteria in my script ?

2) and test in beforeshowform

Another solution is welcomed …

18/03/2010
12:20
Avatar
phicarre
Member
Members
Forum Posts: 132
Member Since:
09/11/2009
sp_UserOfflineSmall Offline

I tried this:

Modification of the string by including a style:

"item1 style='color:red ':item1;item2:item2;…itemn:itemn"

but jQGrid transforms this in:

<option value="item1 style='color">red</option><option value="'">item1</option> etc ...

because the : is a terminator !

18/03/2010
13:31
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

This is not tested, but you can try to build the string like:

"item1:<font color='red'>item1</font>;item2:<font color='green'>item1</font>…."

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.

19/03/2010
13:13
Avatar
phicarre
Member
Members
Forum Posts: 132
Member Since:
09/11/2009
sp_UserOfflineSmall Offline

Hi Tony,

Perfect because no ":"  ...

Thank you.

Maybe an improvement for future release Confused

21/04/2010
19:12
Avatar
phicarre
Member
Members
Forum Posts: 132
Member Since:
09/11/2009
sp_UserOfflineSmall Offline

Oups !

Not perfect because, after the selection in the listbox, the textbox is not filled !

26/04/2010
13:48
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

The clear way IMHO (which work for me) is as follow:

Obtain your select via dataUrl option - the select can be something like this

<select id="s1">
<option class="red" value="1">2</option>
<option class="blue" value="4">3</option>
<option class="green" value="5">4</option>
</select>

Then define in the css:

<style>

    option.blue { color: blue;}
    option.green {color: green;}
    option.red {color:  red;}

</style

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.

26/04/2010
16:48
Avatar
phicarre
Member
Members
Forum Posts: 132
Member Since:
09/11/2009
sp_UserOfflineSmall Offline

Yes Tony, but the first idea was to build the data with the color, server side.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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