-
30 Apr 2011 1:56 AM #1
How to get the selected row of a grid?
How to get the selected row of a grid?
Hi,
In ext js 3.x , i was using the following code in RowSelectionModel to get the selected row in the grid.
On migrating to Ext js 4 , i have changed my code like thisCode:var selHandler = new Ext.grid.RowSelectionModel({ singleSelect : true, listeners: { rowselect: function(smObj, rowIndex, record) { var row = Ext.getCmp('postionGrid').getView().getRow(rowIndex); var element = Ext.get(row); element.removeClass('x-grid3-row-selected'); var cls = ''; var data=record.data; switch (data.position) { case '4' : cls = 'x-grid3-row-selected-4'; break; case '3' : cls = 'x-grid3-row-selected-3' ; break; case '2' : cls = 'x-grid3-row-selected-2' ; break; default: cls = 'x-grid3-row-selected' ; break; } element.addClass(cls); } });
But Ext.getCmp('postionGrid').getView().getRow(index) is not working as View doesnot have getRow() method. So how an i get the Selected Row of the grid, so that i can change its cls.Code:var selHandler = Ext.create('Ext.selection.RowModel',{ singleSelect : true, listeners: { select: function(smObj, record, index) { var row = Ext.getCmp('postionGrid').getView().getRow(index); var element = Ext.get(row); element.removeClass('x-grid3-row-selected'); var cls = ''; var data=record.data; switch (data.position) { case '4' : cls = 'x-grid3-row-selected-4'; break; case '3' : cls = 'x-grid3-row-selected-3' ; break; case '2' : cls = 'x-grid3-row-selected-2' ; break; default: cls = 'x-grid3-row-selected' ; break; } element.addClass(cls); } });
Thanks in advance
-
30 Apr 2011 10:48 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 435
Look at getNode method.
If you want to get the selected then you can use the getSelectedNodesMitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
1 May 2011 11:28 PM #3
Similar Threads
-
Grid with one row selected
By sofway in forum Ext 3.x: Help & DiscussionReplies: 2Last Post: 3 Aug 2010, 12:04 AM -
Use selected rows in Grid 1 to create Grid 2 in new window
By papadiddy in forum Ext 3.x: Help & DiscussionReplies: 0Last Post: 12 Nov 2009, 8:22 PM -
Go to selected row in a grid
By anakin2hawk in forum Ext 2.x: Help & DiscussionReplies: 2Last Post: 15 Jun 2009, 8:21 AM -
more than one row was selected in grid
By michaelc in forum Ext 2.x: Help & DiscussionReplies: 2Last Post: 18 Mar 2008, 12:28 PM -
when a grid when a grid has data and one row selected. will reload the grid datastroe
By linizou in forum Ext 2.x: Help & DiscussionReplies: 0Last Post: 6 Jan 2008, 7:29 PM


Reply With Quote