Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
760
Click UltraWebGrid Column Header, Change Column to Specific Width
posted

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...

Parents
  • 49378
    Suggested Answer
    posted

    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 Ivanov
    Developer Support Engineer
    Infragistics, Inc.
    http://es.infragistics.com/support

Reply Children