Forum


13:57

12/02/2009

jquery 1.3.1
jqGrid 3.4.1
FireFox 3.0.7
Fedora 10 (64-bit)
I am trying to implement the edit buttons as shown in the "Custom Edit" demo. My loadComplete() method is...
loadComplete: function(){
var ids = jQuery(gridName).getDataIDs();
for(var i=0;i<ids.length;i++) {
var cl = ids[i];
alert(cl + ' name:' + gridName);
be = "<input style='height:22px;width:20px;' type='button' value='E' onclick=jQuery('"+gridName+"').editRow("+cl+"); />";
se = "<input style='height:22px;width:20px;' type='button' value='S' onclick=jQuery('"+gridName+"').saveRow("+cl+"); />";
ce = "<input style='height:22px;width:20px;' type='button' value='C' onclick=jQuery('"+gridName+"').restoreRow("+cl+"); />";
alert(be+se+ce);
jQuery(gridName).setRowData(ids[i],{act:be+se+ce});
}
},
I have verified the colNames and colModels contain the same number of elements and that the colNames and ColModel.name is 'act'. The be+se+ce string is....
<input style='height:22px;width:20px;' type='button' value='E' onclick=jQuery('#grid').editRow(1); />
<input style='height:22px;width:20px;' type='button' value='S' onclick=jQuery('#grid').saveRow(1); />
<input style='height:22px;width:20px;' type='button' value='C' onclick=jQuery('#grid').restoreRow(1); />
(I did notice in the demo code there was what seemed to be a spurious '></ids>' at the end of the first input which I removed)
My call is ...
jQuery(gridName).setRowData(ids[i],{act:be+se+ce});
In each case I get then elem[0] is undefined in grid.base.js line 715.
If I change the 'act' to 'xxx', I get no error and obviously no buttons.
What am I missing?
03:17

Moderators
30/10/2007

Hello,
Do you have defined a act coulmn in the colModel?
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.
06:12

12/02/2009

Tony,
Yes. The thing I am doing differently from the example is that I have queried the database table I wish to edit for its schema so that I can build a table dynamically. First I build an array of colNames and colModels, then I use them to define the grid. Using the javascript debugger, I have verified that colNames[7] is "act" and colModel[7] is {index : "act", name : "act", sortable : false, width : 75} when used in the jqGrid constructor.
I have no reason to suspect any problem as the table is properly populated with the data from the table.
Thanks for any help you may have, and thanks as well for this marvelous plugin.
-- John
08:06

Moderators
30/10/2007

Hello,
Try to use gridComplete and not loadComplete.
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:34

12/02/2009

Tony,
I changed loadComplete() to gridComplete() and observed the same behaviour.
In stepping through the code, I observe this is a problem selecting the object. The selector is "td:eq(7)", but at the time of the call there are only 7 columns in the grid with the result that an object of length 0 is passed into the formatter.
All column headings are displayed, but it seems the body of the grid has not yet had the column for the buttons added. In fact, below the "Actions" heading there appears to be nothing (no zebra stripes). I have attempted to put the buttons on the right of the grid, while the example has them on the left.
Is there something I should do to force this column to be present?
Thanks!
-- John
08:50

12/02/2009

Tony,
I added another column to my database query to return a blank 'act' column with the result that I had a grid column defined. Now I have buttons. That is, my database query became ...
SELECT invid,invdate,client_id,amount,tax,total,note, '' as act FROM invheader ORDER BY invid asc LIMIT 0 , 10
By adding the " ' ' as act " to the query, the json reader created the extra grid column I needed.
Is there a better way to do this?
Thanks,
-- John
11:22

Moderators
30/10/2007

Hello,
This is the right way.
Reagrds
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.
13:09

12/02/2009

Tony,
After reading this, I went back to the demo code and noticed the empty string as the first element of the array to correspond to the 'act' column.
I suppose I should have gotten the demo working first to build confidence, but I am sometimes too impatient.
Do you think a comment in the demo code explaining that would be valuable? I'm sure you have enough to do, but it would have helped me. You could, in fact, change the empty string to "act placeholder" to illustrate the point. Just a thought!
Thanks,
-- John
Most Users Ever Online: 715
Currently Online:
51 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66