Hello everyone,
i am trying to hide columns in a RadGrid through the OnColumnCreated-event in the code-behind.
The Radgrid is bound to the Data in the PageLoad by just assigning a DataTable as DataSource.
On the clientside the hidden columns should really just be hidden, so that i can access them through JavaScript because i want to react on OnRowClick and need the information.
The OnRowClick then does an async postback by using the RadAjaxManager and then i can handle everything in the code behind but i still need those values.
How can i hide columns and still get access them on the client side?
Or is there a way to use just the rownumber to get the Row and its values on the server side?
i am trying to hide columns in a RadGrid through the OnColumnCreated-event in the code-behind.
The Radgrid is bound to the Data in the PageLoad by just assigning a DataTable as DataSource.
On the clientside the hidden columns should really just be hidden, so that i can access them through JavaScript because i want to react on OnRowClick and need the information.
var
grid = sender;
var
MasterTable = grid.get_masterTableView();
var
row = MasterTable.get_dataItems()[args.get_itemIndexHierarchical()];
var
value1= MasterTable.getCellByColumnUniqueName(row,
"HiddenRow1"
).innerHTML;
var
value2= MasterTable.getCellByColumnUniqueName(row,
"HiddenRow2"
).innerHTML;
The OnRowClick then does an async postback by using the RadAjaxManager and then i can handle everything in the code behind but i still need those values.
How can i hide columns and still get access them on the client side?
Or is there a way to use just the rownumber to get the Row and its values on the server side?
10 Answers, 1 is accepted
0
Accepted
Princy
Top achievements
Rank 2
answered on 17 Apr 2012, 11:22 AM
Hello Marcel,
Try hiding the column using Display property rather than Visible property and then access the cell value. Here is the sample code that I tried which worked as expected.
C#:
Thanks,
Princy.
Try hiding the column using Display property rather than Visible property and then access the cell value. Here is the sample code that I tried which worked as expected.
C#:
protected
void
RadGrid1_ColumnCreated(
object
sender, Telerik.Web.UI.GridColumnCreatedEventArgs e)
{
if
(e.Column.UniqueName ==
"UniqueName"
)
{
GridBoundColumn col = (GridBoundColumn)e.Column;
col.Display =
false
;
}
}
Thanks,
Princy.
0
Marcel
Top achievements
Rank 1
answered on 17 Apr 2012, 12:22 PM
Works perfectly!
Thanks.
Thanks.
0
Srujan
Top achievements
Rank 1
answered on 07 Oct 2014, 07:07 PM
Hi Princy ,
I have a masterdetail table , I am unable to hide column in details view , can you please suggest how to proceed .
I have a masterdetail table , I am unable to hide column in details view , can you please suggest how to proceed .
0
Hi Srujan,
You can achieve this requirement either on server or client-side by using the Name property of the table views:
Hope this helps.
Regards,
Eyup
Telerik
You can achieve this requirement either on server or client-side by using the Name property of the table views:
<
telerik:GridTableView
...
Name
=
"Customers"
>
Hope this helps.
Regards,
Eyup
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
C
Top achievements
Rank 1
answered on 19 Nov 2014, 10:50 AM
Hmmm, in my grid, the ColumnCreated event only fires for "ExpandCollapseColumn". It doesn't seem to fire for my GridBoundColumns?
0
Hello,
The RadGrid ColumnCreated event should fire for all kind of columns in RadGrid. Please make sure that you handle the event correctly and also that you are setting a breakpoints for the event itself and not for some condition in the handler which is not hit for Bound Columns.
Regards,
Maria Ilieva
Telerik
The RadGrid ColumnCreated event should fire for all kind of columns in RadGrid. Please make sure that you handle the event correctly and also that you are setting a breakpoints for the event itself and not for some condition in the handler which is not hit for Bound Columns.
Regards,
Maria Ilieva
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
C
Top achievements
Rank 1
answered on 24 Nov 2014, 10:31 AM
Yeah, well, I can't seem to get it to work.
<telerik:RadGrid ...
OnColumnCreated="rgActivities_OnColumnCreated" ...>
...
</telerik:RadGrid>
protected void rgActivities_OnColumnCreated(object sender, GridColumnCreatedEventArgs e)
{
if (e.Column.UniqueName != "EventDateID")
return;
var col = (GridBoundColumn)e.Column;
col.Display = false;
}
<telerik:RadGrid ...
OnColumnCreated="rgActivities_OnColumnCreated" ...>
...
</telerik:RadGrid>
protected void rgActivities_OnColumnCreated(object sender, GridColumnCreatedEventArgs e)
{
if (e.Column.UniqueName != "EventDateID")
return;
var col = (GridBoundColumn)e.Column;
col.Display = false;
}
0
Hi C,
Can I kindly ask you to open a regular support ticket and send us isolated runnable version of your application? Thus we will be able to debug it locally and verify what exactly is causing the ColumnCreated event to not fire correctly.
Regards,
Maria Ilieva
Telerik
Can I kindly ask you to open a regular support ticket and send us isolated runnable version of your application? Thus we will be able to debug it locally and verify what exactly is causing the ColumnCreated event to not fire correctly.
Regards,
Maria Ilieva
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Graham
Top achievements
Rank 1
answered on 12 Jan 2016, 04:01 PM
I'm observing the same behavior as 'C': the ColumnCreated event only fires for "ExpandCollapseColumn". It doesn't fire for any of the GridBoundColumns.
0
Hi Graham ,
Note that this event fires only for auto-generated columns.
Regards,
Maria Ilieva
Telerik
Note that this event fires only for auto-generated columns.
Regards,
Maria Ilieva
Telerik
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 Feedback Portal
and vote to affect the priority of the items