3 Answers, 1 is accepted
0
Jayesh Goyani
Top achievements
Rank 2
answered on 30 Jan 2014, 04:41 AM
Hello,
Thanks,
Jayesh Goyani
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" OnNeedDataSource="RadGrid1_NeedDataSource" AllowFilteringByColumn="true" OnItemDataBound="RadGrid1_ItemDataBound"> <MasterTableView DataKeyNames="ID"> <Columns> <telerik:GridBoundColumn DataField="ID" UniqueName="ID" HeaderText="ID"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Name" UniqueName="Name" HeaderText="Name"> </telerik:GridBoundColumn> </Columns> </MasterTableView> </telerik:RadGrid>protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { List<Employee> list = new List<Employee>(); ; Employee obj = new Employee(); obj.ID = "1"; obj.Name = "Name1"; list.Add(obj); obj = new Employee(); obj.ID = "2"; obj.Name = "Name2"; list.Add(obj); RadGrid1.DataSource = list; } protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridFilteringItem) { GridFilteringItem item = e.Item as GridFilteringItem; (item["ID"].Controls[0] as TextBox).Attributes.Add("AttributeName","AttributeValue"); } }Thanks,
Jayesh Goyani
0
Princy
Top achievements
Rank 2
answered on 30 Jan 2014, 04:58 AM
Hi Pavel,
I guess you want to access the GridFiltering TextBox and set some attributes to it. Please try the following code snippet:
C#:
JS:
Thanks,
Princy
I guess you want to access the GridFiltering TextBox and set some attributes to it. Please try the following code snippet:
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e){ if (e.Item is GridFilteringItem) { GridFilteringItem item = (GridFilteringItem)e.Item; TextBox txtBox1 = (TextBox)item["ColumnUniqueName"].Controls[0]; txtBox1.Attributes.Add("onclick", "return OnClick();"); // Adding OnClick event }}JS:
<script type="text/javascript"> function OnClick() { alert("TextBox Click"); }</script>Thanks,
Princy
0
Pavel
Top achievements
Rank 1
answered on 30 Jan 2014, 03:57 PM
Thank you, both!