Opened 12 years ago

Closed 11 years ago

#11098 closed defect (wontfix)

dojox.DataGrid sorting problem when passing field="_item"

Reported by: Fausto Lemos Owned by: Bryan Forbes
Priority: high Milestone: 1.7
Component: DojoX Grid Version: 1.4.0
Keywords: Cc:
Blocked By: Blocking:


Hello guys!

i was building a grid and see the following problem:

when passing "_item" as a parameter value to "field" attribute, the column sort of the grid doesn't work properly.

<th field="_item" width="80px" formatter="formatX">Test</th>

My "formatX()" digs the "_item" object and return a string with the respective value.

can you guys confirm that?

Change History (7)

comment:1 Changed 12 years ago by asahlin

I am seeing the same issue. I have a custom datastore specified on my datagrid. When clicking on the column header to sort, the datastore fetch method is being passed _item as the attribute in the sort object. Since my datagrid has several columns where I specify _item (I do this so my formatter has the needed information to do my custom rendering) my datastore has no idea what column was clicked on as it doesn't have any columns with id of _item.

How is this intended to work. It appears to me that <th> field has been overloaded and you either get one or the other a) the item passed to your formatter, but no sorting or b) thin formatters and sorting. Am I missing something or is this a bug.

comment:2 Changed 12 years ago by bill

Owner: changed from bryanforbes to Bryan Forbes

comment:3 Changed 12 years ago by moiz

I am also looking for a solution to this. Is there any other way around to get this working? something like for sort using some other attribute field?

comment:4 Changed 12 years ago by evan

Don't think this is a defect, needs to close it.

field = "_item" is a rare scenario to provide more control for formatter() since the rowItem is passed along instead of value, the following work around would be needed to make sorting work:

var f = g.getSortProps;/*grid*/ 
g.getSortProps = function(){ 
        var info = dojo.hitch(g, f)(); 
        if(info[0] && info[0]['attribute'] === '_item'){ 
                info[0]['attribute'] = 'col1' //set to reall item field for single sorting 
        return info; 

comment:5 in reply to:  4 Changed 12 years ago by Fausto Lemos

Hello Evan,

i think this is a bug, because when you informe the column name instead of "_item" the sort occurs perfect.

About the work around you suggested, where should i use him?


comment:6 Changed 11 years ago by evan

Milestone: tbd1.7

Please note in order to make sorting work correctly, there needs to be a real field in datastore - just as the above workaround suggested(burns, you can use it once your grid is instantiated.)

So this is not a defect but a new usage requirement - need a way to identify a real field for sorting for a column with field = "_item". Deferring to further since we're closing to 1.6.

comment:7 Changed 11 years ago by evan

Resolution: wontfix
Status: newclosed

Closing as 'wontfix' in existing Grid, a similar feature will be supported in new Grid(Gridx - #11903), e.g. we can have a column without any corresponding fields, but still do sort well with a configured comparator map

Note: See TracTickets for help on using tickets.