:: Forum >>

Sort GRID Items based onthe Header Name

Hello Support Team,

I am using a Active Widgets GRID and I want to set the sort Format of the column based on the header name.

i.e., If the Header Name is "Date" then the "AW.Formats.Number" must be set dynamically after building the GRID.

If the case is with the static columns then that is working fine, and I'm able to set the sort format of the columns.

I've a requirement where the columns will be generated dynamically and the grid will reload / change the columns when we click on a button on that page. So, how to set the sort format in this case.

I'm Using C#.Net for generating the columns and building the GRID dynamically. - This is FYI

Thank you very much for your help In advance.
Thursday, December 3, 2009
Assuming that your headers are set dynamically (and that the C# prints out into a javascript array), simply analyze the header array and set the formats for those columns based on their names.

I think something like this should work...
myHeaders = ["Date","Number","Text","Date"]; //This is set dynamically

//Prepare the formats that the columns will be assigned
var dateFormat = new AW.Formats.Date;
dateFormat.setDataFormat("ISO8601"); //date format from the db
dateFormat.setTextFormat("yyyy-mm-dd"); //date format to display
var numbFormat = new AW.Formats.Number;
numbFormat.setErrorText(""); //suppress empty/non-numeric values
var textFormat = new AW.Formats.String;

var headerLen = myHeaders.length;
for(var i = 0;i<headerLen;i++){
var curFormat = "";
case "Date":
curFormat = dateFormat;
case "Number":
curFormat = numbFormat;
curFormat = textFormat;

Also, you should look at the format AW.Formats.Date for your date columns. It's very useful for working with dates, as you can store dates in the database and then display them differently without having to mess with converting them between formats yourself.
Friday, December 4, 2009

This topic is archived.

Back to support forum

Forum search