Forum


09:06

23/07/2008

Hey,
When I build the jqGrid I'm creating a column that has a ddl(DropDownList) for each row.
Here is how the column is defined :
{ name: 'Location', index: 'Location', width: 90, editable: true, edittype: "select", editoptions: { value: 'R :Rochester;MA :Massachusetts;DL :Data Librarian;Buff :Buffalo / Niagara Falls;Bing :Binghamton / Owego / Southern Tier;Other :All other locations;Alb:Albany and all points East;'}}]
When the grid is created dynamically the Location column contains a text of the item that should be selected.
When the user clicks the edit Row button, $("#list").editRow(rowNum); gets called and the ddl is displayed, as planned. I'm having trouble trying to set the selected item. I know I can use $("#ddl").selectOptions(index", true);
BUT heres the issue I can't grab $("#ddl"). I don't know how to get the dom object from cell in the grid.
I used var locationData = $("#list").getRowData(rowNum).Location; But this returns the html that creates the ddl. ie
<SELECT id=1_Location class=editable><OPTION value="R ">Rochester</OPTION><OPTION selected value="MA ">Massachusetts</OPTION><OPTION value="DL ">Data Librarian</OPTION><OPTION value="Buff ">Buffalo / Niagara Falls</OPTION><OPTION value="Bing ">Binghamton / Owego / Southern Tier</OPTION><OPTION value="Other ">All other locations</OPTION><OPTION value="Alb ">Albany and all points East</OPTION><OPTION value=""></OPTION></SELECT>
As a hack to get this to work I'm doing this. I shouldn't need to parse the list every time and create a new ddl and set the selected item. I should be able to use the one that is created when the row is created.
var locationSelect = document.createElement("select");
var arrayLocations = ('R :Rochester;MA :Massachusetts;DL :Data Librarian;Buff :Buffalo / Niagara Falls;Bing :Binghamton / Owego / Southern Tier;Other :All other locations;Alb :Albany and all points East;').split(";");
for (var i = 0; i < arrayLocations.length - 1; i++) {
var optionItem = document.createElement("option");
optionItem.value = trim(arrayLocations[i].split(":")[0]);
optionItem.text = trim(arrayLocations[i].split(":")[1]);
//check if this should be the selected item.
if (arrayLocations[i].indexOf(rowData.Location) != -1)
optionItem.selected = true;
locationSelect.add(optionItem);}
Any help would be awesome.
Thanks
Brad
09:17

Moderators
30/10/2007

Hello,
What you use inline edit, cell edit or form edit?
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.
10:13

Moderators
30/10/2007

Hello,
If the text data is equal from those provided with the select this should work. Check to se if the data in edit options in colModel are the same as those in the grid.
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.
14:17

23/07/2008

I think I understand what you're asking...
Here is the text used to create the select box in colModel (this works)
editoptions: { value: 'R :Rochester;MA :Massachusetts;DL :Data Librarian;Buff :Buffalo / Niagara Falls;Bing :Binghamton / Owego / Southern Tier;Other :All other locations;Alb:Albany and all points East;'}
When I do this in the edit row function I get the following text.
$("#list").editRow(rowNum.toString());
var dropDownData = $("#list").getRowData(rowNum).Location;
the value of dropDownData is
<SELECT id=1_Location class=editable><OPTION value="R ">Rochester</OPTION><OPTION value="MA ">Massachusetts</OPTION><OPTION value="DL ">Data Librarian</OPTION><OPTION value="Buff ">Buffalo / Niagara Falls</OPTION><OPTION value="Bing ">Binghamton / Owego / Southern Tier</OPTION><OPTION value="Other ">All other locations</OPTION><OPTION selected value="Alb ">Albany and all points East</OPTION><OPTION value=""></OPTION></SELECT>
The dropdownList appears when I'm editing the row. But I can't set the selected item. Everytime a user clicks the edit button the first item in the dropdownlist is always selected. I have the index and text of the item that needs to be selected. I just don't know how to do it.
I'm assuming that i would use XXX.selectOptions(index, true); but I don't know how to get the XXX(ddl object) to use it on......
Understand my problem.
08:21

Moderators
30/10/2007

Hello,
If this will resolve you problem - if you save the row we post the value to the server, but not the text. After saving we set the text again. Maybe you should not do anything.
(getRowData is NOT compatible when you edit the row)
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.
Most Users Ever Online: 715
Currently Online:
53 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66