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

Grid Resize to column width

2 Answers 126 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Morten
Top achievements
Rank 1
Iron
Iron
Veteran
Morten asked on 13 May 2008, 08:43 AM
in a RadGrid for asp.net project I use this script to resize a grid to the sum of width of grid's columns:

    <ClientSettings>
      <ClientEvents OnGridCreated="GridCreated" />
    </ClientSettings>

function GridCreated()
{
  //resize radgrid to fit columns
  this.MasterTableView.Control.style.width = "";
  this.Control.style.width = this.MasterTableView.Control.offsetWidth + "px";
}

The same code does not work in a new RadGrid for asp.net ajax project. I get the js error message:

this.MasterTableView.Control is null or not an object

Must I do the grid resizing differently in radgrid for asp.net ajax?

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 13 May 2008, 02:29 PM
Hello Morten,

There are some changes in the client-side programming for RadGrid for ASP.NET AJAX, which have been introduced so that the control uses ASP.NET AJAX conventions.

Please replace your old code with this:

function GridCreated(sender, eventArgs) 
    sender.get_masterTableView().get_element().style.width = ""
    sender.get_element().style.width = sender.get_masterTableView().get_element().offsetWidth + "px"


In addition, you can find these help articles handy:

http://www.telerik.com/help/aspnet-ajax/grdmigrationtoprometheus.html

http://www.telerik.com/help/aspnet-ajax/grdgettingfamiliarwithclientapi.html


Let us know if you need more information.


Greetings,
Dimo
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Morten
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 13 May 2008, 09:56 PM
Bingo! Thanks a lot.
Tags
Grid
Asked by
Morten
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Dimo
Telerik team
Morten
Top achievements
Rank 1
Iron
Iron
Veteran
Share this question
or