This is a migrated thread and some comments may be shown as answers.
GridBoundColumn does not work client side when inherited
3 Answers 31 Views
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 26 Feb 2011, 12:31 AM
Hello Telerik Team,

I have a grid that I bind on the client side.

I want to create a custom filtering column for my grid.  I have successfully derived from GridBoundColumn to create GridFilteringBoundColumn.  I override the SetupFilterControls method and all is well.

However, I also have a GridButtonColumn that I would like to be able to filter on.  If I derive from GridButtonColumn in the same exact way as above, the cells do not get rendered as hyperlinks and clicking on the text in the cell does nothing (I expect it to do a fireCommand with my command name that I assigned.

I have verified with a debugger that the CommandName property is set correctly but I can't figure out why the cells do not render properly. In the browser, when I use the Telerik GridButtonColumn, the cells all contain text of this form:

<a onclick="if(!$find('ctl00_WebPartManager_WorkAreaWebPart_MainControl_WorkAreaGrid_ctl00').fireCommand('DisplayDetails','0')) return false;" href="javascript:__doPostBack('ctl00$WebPartManager$WorkAreaWebPart$MainControl$WorkAreaGrid$ctl00$ctl04$ctl01','')">J1542A</a><br>

but with my derived Column, all I get is simpletext after the grid binds on the client side.

What am I missing?

Thanks
Bob

3 Answers, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 03 Mar 2011, 09:35 AM
Hi Bob,

The GridButtonColumn does not support filtering by default. This is because the rendered button can be other types besides LinkButton (i.e. ImageButton) and in those cases the filtering will not make sense. If you have only links in the button column one possible option is to use GridHyperLinkColumn instead to achieve the same effect but this time filtering functionality comes by default.

Regards,
Marin
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
Bob
Top achievements
Rank 1
answered on 03 Mar 2011, 02:17 PM
That is fine.  I am not looking to support filtering.  But I need to manage the (empty) table cell where the filtering icon would go.  This is the table cell between the header row and the grid.  For all my other Filtering columns, I set the alignment to Center for my filter icon.  The problem arises when I programatically reorder columns.  If I reorder a filtering column with this gridbutton column, the centering is lost when the filtering column moves into the spot where this GridButton column was.

So even though I do not need filtering, I need a way to set the alignment of the cell that gets created,

And also, why do the GridButton cells lose their formatting (no underline, no hyperlink) just because I created a derived class?
0
Marin
Telerik team
answered on 08 Mar 2011, 07:04 PM
Hi Bob,

The text in the cells of the GridButtonColumn will be rendered as a hyperlink only if the ButtonType of the column is LinkButton and you have either handled the client OnCommand event for the grid or you are using client-side data binding. Additionally you can override the ClientClickScript method of the column to return the correctly formatted string of the following form regardless of other conditions

if(!$find('client ID of masterTableView').fireCommand(...)

As for the cell formatting - filter items for columns that do not support filtering are not styled by default and also the SetupFilterControls method is not called for such columns. The boolean SupportsFiltering method determines whether a column will support filtering or not. You can globally apply style to the filtering item using similar css rule (more info here):
.rgFilterRow td
{
    //set alignment here !important
}
or programmatically this should be done in the InitializeCell method of the column.

Best wishes,
Marin
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!
Tags
Grid
Asked by
Bob
Top achievements
Rank 1
Answers by
Marin
Telerik team
Bob
Top achievements
Rank 1
Share this question
or