-
21 Nov 2006 11:18 AM #1
grid sort marks all rows by the first column
grid sort marks all rows by the first column
I have a really wierd issue. You can see the code below. Essentially I have two different possible values (actually images) in the first column. When I have no row selected I can sort and nothing gets automatically selected. But if I now select a row and now click on any of the sort buttons, it automatically selects all rows that have the same value/image in the first column.
Code:<style> .message_list{ float:right; width:600px; border:1px solid #c3daf9; border-top:1px solid #DCEAFB; border-left:1px solid #DCEAFB; font-size:10px; padding:8px; } </style> <script type="text/javascript" language="javascript"> // <![CDATA[ var message_list = { init : function(){ var myData = [ ['[img]read.jpg[/img]','Aril29','Lorem ...','12.11.2006','MMS','100kb'], ['[img]unread.jpg[/img]','Aril29','Lorem ...','12.11.2006','MMS','300kb'], ['[img]read.jpg[/img]','Sandy-from-the-sun','Lorem ...','12.11.2006','MMS','300kb'], ['[img]unread.jpg[/img]','Aril29','Lorem ...','12.11.2006','MMS','220kb'], ['[img]unread.jpg[/img]','Aril29','Lorem ...','12.11.2006','MMS','230kb'], ['[img]read.jpg[/img]','ZONE','Lorem ...','12.11.2006','SMS',''], ['[img]read.jpg[/img]','Aril29','Lorem ...','12.11.2006','MMS','300kb'], ['[img]read.jpg[/img]','Sandy-from-the-sun','Lorem ...','12.11.2006','MMS','300kb'], ['[img]unread.jpg[/img]','Sandy-from-the-sun','Lorem ...','12.11.2006','SMS',''], ['[img]read.jpg[/img]','Aril29','Lorem ...','12.11.2006','SMS',''], ['[img]unread.jpg[/img]','ZONE','Lorem ...','12.11.2006','MMS','80kb'], ['[img]unread.jpg[/img]','Aril29','Lorem ...','12.11.2006','SMS',''], ['[img]read.jpg[/img]','Aril29','Lorem ...','12.11.2006','MMS','150kb'], ['[img]read.jpg[/img]','Aril29','Lorem ...','12.11.2006','MMS','120kb'], ]; var dataModel = new YAHOO.ext.grid.DefaultDataModel(myData); // the DefaultColumnModel expects this blob to define columns. It can be extended to provide // custom or reusable ColumnModels var colModel = new YAHOO.ext.grid.DefaultColumnModel([ {header: "", width: 40, sortable: true}, {header: "Absender", width: 130, sortable: true}, {header: "Text", width: 330, sortable: true}, {header: "Datum", width: 75, sortable: true}, {header: "Art", width: 50, sortable: true}, {header: "Anhänge", width: 85, sortable: true} ]); // create the Grid var grid = new YAHOO.ext.grid.Grid('message_list', dataModel, colModel); var start = new Date().getTime(); grid.render(); } } YAHOO.ext.EventManager.onDocumentReady(message_list.init, message_list, true); // ]]> </script> <div id="message_list" style="border: 1px solid #cccccc; overflow: hidden; width: 710px; height: 360px;"></div>
-
21 Nov 2006 11:25 AM #2
Selections are maintained by the row's id. In a DefaultDataModel, the default row id is the value in the first column. You will need to provide a function to return a true row id.
The default is:Code:dataModel.getRowId = function(rowIndex){ return (your id for this row); };
Code:getRowId : function(rowIndex){ return this.data[index][0]; }
-
21 Nov 2006 1:48 PM #3
ah cool thx ..
can i have a "hidden" column which i can use as the first column (or as the source of the unique row id)?
seems like the easiest solution ..
-
21 Nov 2006 2:04 PM #4
Yes. You can do something like:
Code:var dm, cm, sm, grid, rowIndex=0; cm = new YAHOO.ext.grid.DefaultColumnModel( [{header:'Index', hidden:true /*width:50*/}, {header:'type', hidden:true}, {header:'Name', width: 90}, {header:'Code', width: 50}, {header:'Viewable', width:65, editor:new YAHOO.ext.grid.CheckboxEditor(), renderer:renderBool} ]); cm.defaultSortable = true; // data schema. // rowIndex is a dummy column that will hold an auto-generated row number // __type will be hidden by the cm var schema = { root:'States', id:'use-index', fields: ['rowIndex', '__type', 'Name', 'Code', 'IsContentViewable'] }; dm = new YAHOO.ext.grid.JSONDataModel(schema); dm.onLoad.subscribe(onLoad.createDelegate(this)); // handle data load event dm.onLoadException.subscribe(showError.createDelegate(this)); // handle load error event dm.addPreprocessor(0, function() {return ++rowIndex;}); // incr the rowIndex as each row is added dm.on('beforeload', function() {rowIndex = 0;}); // init the rowIndex before load dm.loadData(data);Tim Ryan
Read BEFORE posting a question / BEFORE posting a Bug
Use Google to Search - API / Forum
API Doc (4.x | 3.x | 2.x | 1.x) / FAQ / 1.x->2.x Migration Guide / 2.x->3.x Migration Guide
-
21 Nov 2006 2:25 PM #5
BTW, I couldn't help but notice you have the dreaded extra comma bug as well.
['[img]unread.jpg[/img]','Aril29','Lorem ...','12.11.2006','SMS',''],
['[img]read.jpg[/img]','Aril29','Lorem ...','12.11.2006','MMS','150kb'],
['[img]read.jpg[/img]','Aril29','Lorem ...','12.11.2006','MMS','120kb'], <-- extra comma
];
-
21 Nov 2006 11:29 PM #6
-
22 Nov 2006 3:58 AM #7
one more question .. is there anywhere a description of the style sheet classes? specifically I have a few icons I need to display which have a greater height than the default. similarily i would like to vertical align things in the middle. so i guess the general question is what classes are useful when styling column cells?
-
22 Nov 2006 8:13 AM #8
You could
a) read the source and see how the HTML elements are built, or
b) if you use FF and an extention like WebDeveloper you can mouseover html elements and see the css classes and html ids of any element.
At some point the CSS files may get documented, but IMO, I would think that's a lower priority than getting all the code documented.Tim Ryan
Read BEFORE posting a question / BEFORE posting a Bug
Use Google to Search - API / Forum
API Doc (4.x | 3.x | 2.x | 1.x) / FAQ / 1.x->2.x Migration Guide / 2.x->3.x Migration Guide
-
22 Nov 2006 9:13 AM #9
Using Firefox, install the Firebug (http://www.getfirebug.com/) extension and use the Inspect option to mouse over your page and examine css classnames, element ids, etc. on the fly. It will change the way you debug your pages, especially when trying to figure out foreign stylesheets and/or see how your style tags are getting rendered.
Similar Threads
-
Problem with column sort
By yevgen in forum Ext 1.x: BugsReplies: 3Last Post: 2 Apr 2009, 2:32 AM -
Send sort column number in paged grid in Ext 1.0
By JeffHowden in forum Community DiscussionReplies: 3Last Post: 2 Jun 2008, 11:16 AM -
column sort makes ajax call for each time grid was recreated
By lemontree in forum Ext 1.x: Help & DiscussionReplies: 6Last Post: 4 Jul 2007, 2:14 AM -
Grid: Post column name (not just id) in remote sort
By brondsem in forum Community DiscussionReplies: 2Last Post: 18 Feb 2007, 4:01 PM -
Grid Sort for formatted date column in FF vs IE6
By mrim in forum Ext 1.x: Help & DiscussionReplies: 5Last Post: 31 Oct 2006, 8:28 PM


Reply With Quote