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
Cell Values when select is used
12/08/2009
17:46
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

I have a grid that has drop down lists for each of the cells in the row.  The primary issue I have is that the value of the selected option should be different that the actual description that displays in the list.  For example You might have a list of employees like this:

<select>
  <option value="1">Bob</option>
  <option value="2">John</option>
  <option value="3">Tony</option>
  <option value="4">Ralph</option>
</select>

If the cell contained the value "3", then when I click on the drop down, it should position it to "Tony" (value 3).  Instead, it positions it at the first value.

I load the grid with the *values* that correspond to the descriptions (eg 1,2,3,4) and I want the grid to position to the correct option in the list.  But, it doesn't.  The only time that the list positions to the correct value is when I have BOTH the value and description match.  Like this:

<select>
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
</select>

Then if the cell has the value of 3, when the drop down list is triggered, it is already positioned at "3" in the list.

I set the drop down lists using the setColProp method:
 .setColProp('emp',{edittype:"select",editoptions:employees})

In this case, the variable employees contains the name:value pairs of the employees.

Am I doing something wrong here?  Positioning the list to the value, rather than the description of the select options seems like the practical way to have this work but I can't seem to make it work.  I always have to have the option value and option description match the value in the cell.

Ideas? Suggestions?

Thanks

14/08/2009
17:50
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

Anyone?

Juan posted what I think was a similar issue in his post "trying to create to dependant dropdowns".  I kind of got lost in all the code though.

This seems to be pretty standard requirement:

When you select a value from a dropdown, it retrieves the id value.  When you trigger a dropdown it should postion to the id value rather than the cell value.

If I am doing something incorrect, let me know.  In the example above, selecting "Tony" from the dropdown list stores "3" in the cell and displays "Tony".  I just want the reverse of that to be true as well: I want the select list to position to the "3" value but display "Tony" in the cell.

Ideas?

14/08/2009
20:34
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

This is a bug I think.  I have been looking at code and debugging for a couple of hours and narrowed it down to this code in grid.common.js (3.4.4)

At around line 191 is a line that has the following:

if (!msl &&  oSv[key]==vl){ ov.selected ="selected"};

oSv[key] returns the text, not the value of the hash key so if you change it to this:

if (!msl &&  key==vl){ ov.selected ="selected"};

Then the code works correctly.

Check my assumptions though.  I am not a very strong javascript programmer.  But it IS working for me not.  When I click on the drop down, it positions to the initial value correctly.

15/08/2009
03:05
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

You do not need to change the code. There is a special option for this purpose in 3.4 and in 3.5 - you just need to read the docs.

colModel :[

{...... formatter:'select'...}

....

]

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.

15/08/2009
21:07
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

Thanks Tony.  I had read the documentation but it is pretty extensive and the initial read on formatter didn't seem to fit.  But those  changes did make the select work like I expected. That introduced a new problem with the 'savedRow' data.  I use 'savedRow' to retrieve saved row so I can pass it to my .saverow function so I can compare the "before" and "after" values in the row:

var mySavedRow = $('#subBE').getGridParam('savedRow');

But 'savedRow' now contains the text of the cell than the key value.  In the example above, if I selected "Tony" the key value in the cell should be "3" and the "3" should be passed as the "savedRow" value.  But I see "Tony" instead.  I read through the formatter docs but this looks like something the grid should handle.  I reverted my code changes back to the original but I still get the text of the cell in the "savedRow" parameter rather than the key value.

Did I miss something or do I need to use a different approach?

Thanks again.

17/08/2009
07:15
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

I have made some changes for the selects including adding a unformat for the select. Will publish this in GitHub soon.

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

17/08/2009
08:38
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

Thanks.  I'll look forward to tryng them out

18/08/2009
17:14
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

BTW,  I temporarily added this hack at about line 38 in grid.inlinedit.js to return the value (rather that the text) if the column type is a 'select':

$(this).append(elc);
//elc has what we want when the format type is "select".  Use that value instead
 if({colModel:$t.p.colModel[i]}.colModel.formatter == "select")
  svr[nm]=elc.value;
 //Agin IE
if($t.p.colModel[i].edittype == "select" && $t.p.colModel[i].editoptions.multiple===true && $.browser.msie) {

I am sure there is a better way, but this is working for now.

18/08/2009
18:28
Avatar
jpalac
Australia
Member
Members
Forum Posts: 38
Member Since:
19/08/2009
sp_UserOfflineSmall Offline

Hi - I'm having the same problem in celledit mode - would greately appreciate a solution.

Thanks,

Jo

19/08/2009
06:25
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

I just posted the update to the GitHub - could you please check it and let me known what is. Also I have added unformat select which should do the job.

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/08/2009
10:59
Avatar
markw65
Member
Members
Forum Posts: 179
Member Since:
30/07/2009
sp_UserOfflineSmall Offline

Not yet ready to test any of this, sorry, but I've looked over the changes.

Not much to say, except that I think its doing more or less what /I/ will want (once I get there!).

A couple of observations:

In grid.celledit.js, lines 119 and following:

nm = $t.p.colModel[iCol].name.replace('.',"\\\\.");
switch ($t.p.colModel[iCol].edittype) {
case "select":
if(!$t.p.colModel[iCol].editoptions.multiple) {
v = $("#"+iRow+"_"+nm.replace('.',"\\\\.")+">option:selected",$t.rows[iRow]).val();
v2 = $("#"+iRow+"_"+nm.replace('.',"\\\\.")+">option:selected",$t.rows[iRow]).text();
} else {
var sel = $("#"+iRow+"_"+nm.replace('.',"\\\\."),$t.rows[iRow]), selectedText = [];
v = $(sel).val();

Im not sure - but those three nm.replace(
'.',"\\\\.") look wrong, given the definition of nm...

Also, this looks wrong:
if($t.p.colModel[iCol].formatter && $t.p.colModel[iCol] == 'select') v2 = v;

Note that $t.p.colModel[iCol] is an object, so its not likely to compare == 'select'.

Not sure if you meant to check edittype (which would be redundant, you've already switched on it) or formatter (which I think would be too restrictive - what about custom formatters?).

I think the correct check is just that it *has* a formatter (ie drop the &&...).

Mark

19/08/2009
11:08
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Thanks for this. Fixed in GitHub.

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/08/2009
19:15
Avatar
jpalac
Australia
Member
Members
Forum Posts: 38
Member Since:
19/08/2009
sp_UserOfflineSmall Offline

Hi,

Forgive my ignorance but I've never used GitHub and I see that you've made the changes in the individual

modules and I'm not sure how to concatenate them into my one grid file. 

(with 3.5 I understand all modules are included in the one file when downloaded from the new download manager)

Thanks,

Jo

21/08/2009
03:28
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello Jo,

In this case you shoul wait for the next bugfix release.

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.

21/08/2009
21:49
Avatar
jpalac
Australia
Member
Members
Forum Posts: 38
Member Since:
19/08/2009
sp_UserOfflineSmall Offline

Can you please give an estimate as to when that would be? Just want to make sure it will fit in with my timelines.

Regards,

Jo

07/09/2009
23:18
Avatar
jpalac
Australia
Member
Members
Forum Posts: 38
Member Since:
19/08/2009
sp_UserOfflineSmall Offline

Tony,

Thanks for the new 3.5.3 version. The select option is now loading however when using getChangedCells I get the text value and not the id value of the selected column value. Is there a way to get the ID?

Thanks,

Jo

08/09/2009
09:45
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Thanks. Fixed. (not jet in GitHub)

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.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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