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

dropdown control in radgrid not drawn correctly

1 Answer 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Leonard
Top achievements
Rank 1
Leonard asked on 10 Dec 2011, 07:43 PM

Hi
I'd like some guidance on the best approach to solve a problem with a rad dropdown field in a rad grid.

I have an aspx page in which there is a rad tabstrip with two radtabs.

The contents of the selected rad tab is a radgrid that is programmatically generated ON THE SERVER SIDE, in the code behind.

Each row in the grid can be edited.  The editing feature is implemented by a button in the grids command panel labeled Edit.
When pressed, an ItemDataBound event is fired on the server side, it then seeks the column to be converted to a dropdown, in the currently selected row and modifies it into a  radcombobox.  I'm new to telerik so I'm not certain if the radcombox has a text mode for display and a dropdown for edit.  It does not appear that the specific cell has a unique name, it is identified by selected row and column name only.

My issue is that often, the width of the column is less than the width of the GridDropDown control resulting in the drown down button on the right of the control to not appear unless the width of the column is increased.  The documentation suggests that the way to correct this is to issue a repaint() of the client side control. 

I have several questions:
Since this conversion of the display from text to dropdown is done on the server side, how do obtain the client side control to issue a repaint()?
Is there jquery selector that will just find all the raddropdown controls on the page and refresh them all (sort of like selecting all div tags)?  What is the syntax? and how do I fire it after the server side has made the change to edit mode?

Thanks.  I really appreciate all suggestions.

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 14 Dec 2011, 04:57 PM
Hello Leonard,

The functionality you are seeking could be achieved with GridTemplateColumn. In its ItemTemplate you could place Label control to only show data and in the EditItemTemplate to place the RadComboBox control.

About how to access some cell you are on the right track by getting the row and then to match it with the column's unique name. This is the preferred way for accessing cells, because you could be certain that you are accessing the right cell. More information on accessing cells and rows could be found in this help topic.

You do not need to use repaint to change the size of a give column. Rather than that you could hook the GridCretead client event of RadGrid and in its body to get a reference to the MasterTableView object and then get its columns. When you have the columns you could check by column's unique name what is the index of the desired column and then use the resizeColumn method of MasterTableView client object. Namely:

function GridCreated(sender, args) {
var radGrid = $find('<%= RadGrid1.ClientID %>');
var masterTableView = radGrid.get_masterTableView();
var columns = masterTableView.get_columns();
for (var i = 0; i < columns.length; i++) {
if (columns[i].get_uniqueName() == "PostalCode") {
masterTableView.resizeColumn(i, 500);
}
}
             
}

But this approach is mostly used if you want to resize some column of RadGrid which is not in edit mode. When you are in Edit mode there are other ways to fine tune your layout, like EditFormTemplates, UserControlEditForms. If you use one of these EditForm types you could arrange the layout just the way you want it with all the CSS styles you wish.

As far to the JQuery, yes, you could use it, but is the slower way for such simple scenario, which could be easily achieved with built-in tools and features of RadGrid.

Give these suggestion a try and check whether this is suitable for you.

All the best,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
Leonard
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or