This is a migrated thread and some comments may be shown as answers.

Column resizing with self-referencing hierarchy

5 Answers 179 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matt Okimura
Top achievements
Rank 1
Matt Okimura asked on 11 Aug 2010, 01:45 AM
I have a RadGrid with a self-referencing dataset, and while it expands and collapses fine, column resizing is not working with multiple levels of data.  If the entire grid is collapsed, resizing works fine, but when they are expanded, the cell contents of the highest level rows get resized but the child levels are totally out of alignment.  Is this a known issue?

5 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 16 Aug 2010, 12:54 PM
Hello Richard,

Indeed, the described behavior is rather expected. When you drag the column header to resize it, the column of the particular grid table view is resized but the columns in its nested grid table views. If you want the columns in the nested grid table views to be resized when you resize a column of the MasterTableView, you will need to use custom javascript for that purpose. You can handle the grid OnColumnResized client-side event, and change the width of the desired columns respectively.

Try it out and let me know if need further assistance.

All the best,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sfayet
Top achievements
Rank 1
answered on 07 Mar 2011, 03:38 PM

Column resizing with self-referencing hierarchy

I am new in Telerik and facing the similar problem with Self-Referencing grid when expanded the details table, the master table row get resized but details table grid is not align accordingly. Here is the code block ---

 

  var gColName = null;           

  function onColumnResized(sender, args)

    {                      

     var column = args.get_gridColumn();

     var uniqueName = column.get_uniqueName();

     if(gColName == uniqueName)

      {

         return;

      }               

           

    var grid = $find("<%=ctl_GridView.ClientID %>");

    var masterTableView = sender.get_masterTableView();

    var cols = masterTableView.get_columns();

    var tableWidth = sender.get_element().scrollWidth;

    var detailTables = sender.get_detailTables();

    var detailTableCount = detailTables.length;

                

for (detailTableIndex=0; detailTableIndex < detailTableCount; detailTableIndex++)

   {

    var detailTable = detailTables[detailTableIndex];

    if(detailTable.get_dataItems().length > 0)

      {

        var columns = detailTable.get_columns();

         for(var k=0; k < columns.length; k++)

            {

            if(columns[k].get_uniqueName() == uniqueName)

             {

              columns[k].set_resizable(true);

              gColName = columns[k].get_uniqueName();

              var width = cols[k].get_element().clientWidth ;

              detailTable.resizeColumn(k, width);

              gColName = null;

              columns[k].set_resizable(false);

 

              break;

              }

            }

      }             

  }

  sender.get_element().style.width = tableWidth + "px"

 }


Please help.
Thanks

Rabiul
0
Sfayet
Top achievements
Rank 1
answered on 15 Mar 2011, 02:52 PM
Hi Lana
the Telerik team

please send me your feedback.
In my above code it is consistently increasing the column of the child either I reduce or increase the size of the parent column

Thanks

Rabiul
0
Iana Tsolova
Telerik team
answered on 15 Mar 2011, 04:14 PM
Hi Sfayet,

Can you debug the code and confirm there the column widths are properly set?

Greetings,
Iana
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Jose
Top achievements
Rank 1
answered on 18 Jan 2012, 03:05 PM
This example works if you add a couple of lines:

Add a tag in the aspx file:

<ClientSettings
    <ClientEvents    OnColumnResized="OnColumnResized"  /> 
     <Resizing  AllowColumnResize="true" /> 
</ClientSettings>

Add a js script to the aspx: (It is almost the same script)

var gColName = null;
 
function OnColumnResized(sender, args) {
 
    var column = args.get_gridColumn();
    var uniqueName = column.get_uniqueName();
    if (gColName == uniqueName) {
        return;
    }
    var masterTableView = sender.get_masterTableView();
    var cols = masterTableView.get_columns();
    var tableWidth = sender.get_element().scrollWidth;
    var detailTables = sender.get_detailTables();
    var detailTableCount = detailTables.length;

    for (var detailTableIndex = 0; detailTableIndex < detailTableCount; detailTableIndex++) {
        var detailTable = detailTables[detailTableIndex];
        if (detailTable.get_dataItems().length > 0) {
            var columns = detailTable.get_columns();
            for (var k = 0; k < columns.length; k++) {
                if (columns[k].get_uniqueName() == uniqueName) {
                    columns[k].set_resizable(true);
                    gColName = columns[k].get_uniqueName();
                    var width = cols[k].get_element().clientWidth;
                    detailTable.resizeColumn(k, width);
                    gColName = null;
                    columns[k].set_resizable(false);
 
                    break;
                }
            }
        }
    }
    sender.get_element().style.width = tableWidth + "px";
}
Tags
Grid
Asked by
Matt Okimura
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Sfayet
Top achievements
Rank 1
Jose
Top achievements
Rank 1
Share this question
or