| Page 1 of 1 | [ 3 posts ] |
|
Hi, I've got some code that updates a single selected row in a datatable. I'm finding out the selected row using the following code -
Code: function updateRows() { var recordID = myDataTable_current.getSelectedRows()[0], record = myDataTable_current.getRecord(recordID); var myRecord = record.getData("id"); And then i run this to update that specific row in the database - Code: var putXML = YAHOO.util.connect.asyncRequest("PUT", "http://192.168.1.2:3000/egtable/" + myRecord + "/egvalue"); My question is...my datatable allows multiple rows to be selected...how would I run this code for every row selected rather than just the first selected row? I've spent a long time trying a few different things, but can't find any simple examples on performing an action on multiple rows. Could anyone give me a quick example of how it would be done? Thanks |
|
The DataTable function you use in your updateRows function uses the method .getSelectedRows on your assignment at "var recordID = myDataTable_current.getSelectedRows()[0]". The .getSelectedRows method returns an array of selected rows, it actually returns the record DOM id elements. See http://developer.yahoo.com/yui/docs/YAHOO.widget.DataTable.html#method_getSelectedRows for the method API documentation.
The way you use it above is you are only using the first element, with the "[0]" index. You can simply loop over each element of this Array and access each individual element of the array to get the record to process it however you desire. For some alternative methods of selecting records, specifically using "checkboxes" I highly recommend Satyam's example at http://www.satyam.com.ar/yui/#deleteRowsBy. Satyam's site is a wonderful resource for "all things DataTable", you should review his examples very carefully. Additionally, I worked up a simpler example of multi-selecting rows using either checkboxes or row select some time ago, it is at http://blunderalong.com/pub/dt_select.html. Todd |
|
Thanks alot for the info Todd, I've managed to get it working perfectly using your example on - http://blunderalong.com/pub/dt_select.html
Much appreciated. |
| Page 1 of 1 | [ 3 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group