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://ko.infragistics.com/support
Excellent response Petar. I'll try it.
Thank you for the response. Glad that you were able to resolve your issues. Please let me know if I can be of further assistance.
Best Regards,
Petar IvanovDeveloper Support EngineerInfragistics, Inc.http://ko.infragistics.com/support
I've successfully solved my problem. My issue all along was that some entries in a webgrid dropdown list exceeded the width of the column; consequently, when the user clicked the drop-down list, 4 consecutive items appeared to be identical because of truncation. When the user attempted to grab the right column border and expand the column to fully view the drop-down rows, the adjacent column changed width instead of the column of interest. I learned subsequently that this was because the column to the left was hidden. Because the sequence of the columns are important to me, I did not want to move the hidden column elsewhere in the grid.
I overcame this problem by simply unhiding the hidden column and giving it a width of 1px. I then assigned the column property that disallows resizing for the column that was previously hidden. The user can now successfully expand the column that is too narrow and see full contents of the drop-down list but cannot adjust the width of the formerly hidden column (which I do not want him to view).
Thanks for your help and timely responses.
Please ensure that you have enabled sorting on the grid. To do that you can use:
UltraWebGrid1.DisplayLayout.AllowSortingDefault =Infragistics.WebUI.UltraWebGrid.AllowSorting.OnClient;
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 contact me if you need further assistance with this matter.