PDA

View Full Version : Grid sorting issue.



OFSS_Chennai
22 May 2009, 8:31 AM
I am adding labels and buttons to the status column in our grid please refer below code snippet.
I have sorting features in grid, but while sort on status column it’s sorting is not happening in proper way.

Code Snippet:
column = new SummaryColumnConfig("reportStatus", reportScreenUIConfig.getGridStatus(), 100);
column.setRenderer(new GridCellRenderer(){
public String render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex,
ListStore store) {

String value = null;

final ReportDownloadView rep = (ReportDownloadView)model;
if(rep.getErrorMessage()!= null && rep.getGuinotify().equals("1")) {
value = rep.getErrorMessage();
}elseif(rep.getErrorMessage()!= null && rep.getGuinotify().equals("0")) {
return"<input type='button' class='x-btn' name='"+rep.getErrorMessage()+"' value='"+rep.getErrorMessage()+"' onclick='' />";

}elseif (rep.getProcessedStatus().equals("1") && rep.getFileName() != null && ! rep.getFileName().equals("Not Generated"))
{
value = “Available”;

if(rep.getGuinotify().equals("1")){
value = “Viewed”;
}
}elseif (rep.getFileName() != null && rep.getFileName().equals("Not Generated"))
{
value = “Report Not Available”;
}
else
{
value = “Pending”;
}

if ( value != null) {
StringBuilder html = new StringBuilder();
html.append("<span title='");
html.append(value);
html.append("' >");
html.append(value);
html.append("</span>");
value = html.toString();
}

return value;
}
});
gridColumns.add(column);


Please refer attached snap shot.

darrellmeyer
26 May 2009, 10:25 AM
sort on status column it’s sorting is not happening in proper way
I do not understand what your issue is. And I don't see what the code you posted has to do with sorting of a column. Please provide more information.

OFSS_Chennai
26 May 2009, 8:13 PM
Hi,

I have created Grid having column 'Status' (please refer attached images).

Status column has some html buttons and text as values.

While on sort Status column using default sorting option by clilck on Column header, its not sort properly.

Please refer above code snippet for Grid and Status Column, so that you will come to know what exactly the column values.


Rupesh.

darrellmeyer
28 May 2009, 6:54 AM
If you use the default sorting, the rows will sorted by the model value in the "reportStatus" property. The value returned by the renderer is not used. By default a StoreSorter instance is used to sort the models in the Grid. StoreSorter delegates to it's default comparator (DefaultComparator class) to do the sorting of models based on a property. If you need to provided your own sorting behavior, you can use your own comparator with the StoreSorter.

1. Create a new StoreSorter.
2. Use your own Comparator.
3. Give the new store sorter to the list store.