Simple request but I can't find anything written out there. I just want to click a header on a WebGrid column and have 3 things happen: 1) I don't want the column to sort; 2) I want to have the column width expand to a prescribed size (e.g., 1000px); and 3) I want the column next to it to decrease width (e.g., 20px). Seems like the ColumnClick client-side event would let me do that, but I'm unable to find sample Javascript syntax. I'm using NetAdvantage Version 10.2. Thank...
Hi megryan,
I would suggest that you use the BeforeSortColumnHeader client-side event of the grid. Here is some sample code which would set the height of the column to be sorted and the next column in the grid, while in the same time cancelling the sorting:
function UltraWebGrid1_BeforeSortColumnHandler(gridName, columnId){ //if the column to be sorted is Name if (igtbl_getColumnById(columnId).Key == "Name") { igtbl_getColumnById(columnId).setWidth(150); //get the current index of the column var colIndex = igtbl_getColumnById(columnId).Index; //set the width of the next column igtbl_getGridById(gridName).Bands[0].Columns[colIndex].setWidth(30); //cancels the sorting return true; }}
Please tell me if this helps.
Best Regards,Petar IvanovDeveloper Support EngineerInfragistics, Inc.http://www.infragistics.com/support
Excellent response Petar. I'll try it.
Please contact me if you need further assistance with this matter.
Petar -
I can't seem to get the BeforeSortColumnHandler event to fire. To make it easy, all I have is:
function UltraWebGrid1_BeforeSortColumnHandler(gridName, columnId){//if the column to be sorted is Nameif (igtbl_getColumnById(columnId).Key == "Name") {
alert("Sort");
}}
I have a similar function for the BeforeColumnSizeChangeHandler handler and it's displaying the alert perfectly. Is there a grid or column property I have to set before the BeforeSortColumnHandler handler will fire?
Please ensure that you have enabled sorting on the grid. To do that you can use:
UltraWebGrid1.DisplayLayout.AllowSortingDefault =Infragistics.WebUI.UltraWebGrid.AllowSorting.OnClient;
Best Regards,
Petar IvanovDeveloper Support EngineerInfragistics, Inc.http://www.infragistics.com/support