
majith basha
Top achievements
Rank 1
majith basha
asked on 05 Oct 2010, 08:15 AM
Hi Princy,
As the below code provided by you to vinayak for traversing the detail table data items(GridDataItem).
1. I want access the (GridFooterItem) in the detail table in item data bound event.
As the below code provided by you to vinayak for traversing the detail table data items(GridDataItem).
1. I want access the (GridFooterItem) in the detail table in item data bound event.
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs
e)
{
if (e.Item is GridDataItem
&& e.Item.OwnerTableView.Name == "Detail")
{
GridDataItem item1 = (GridDataItem)e.Item;
DropDownList combo = (DropDownList)item1.FindControl("DropDownList1");
combo.Attributes.Add("onChange", "return Change('" + item1.ItemIndex +
"');");
}
}
The reference link from the code fetched is as follows :
http://www.telerik.com/community/forums/aspnet-ajax/grid/set-value-to-cell-in-detailtables-in-radgrid-using-javascript.aspx
Regards!
Majith.B
4 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 05 Oct 2010, 09:28 AM
Hello Majith,
Check for GridFooterItem instead of GridDataItem as shown below.
Code:
aspx:
Hope this helps,
Princy.
Check for GridFooterItem instead of GridDataItem as shown below.
Code:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridFooterItem && e.Item.OwnerTableView.Name ==
"Detail"
)
{
GridFooterItem footerItem = (GridFooterItem)e.Item;
DropDownList combo = (DropDownList)footerItem.FindControl(
"DropDownListFooter"
);
combo.Enabled =
false
;
}
}
aspx:
<
Columns
>
<
telerik:GridTemplateColumn
UniqueName
=
"DropDown"
>
<
ItemTemplate
>
<
asp:DropDownList
ID
=
"DropDownList1"
runat
=
"server"
>
</
asp:DropDownList
>
</
ItemTemplate
>
<
FooterTemplate
>
<
asp:DropDownList
ID
=
"DropDownListFooter"
runat
=
"server"
>
</
asp:DropDownList
>
</
FooterTemplate
>
</
telerik:GridTemplateColumn
>
Hope this helps,
Princy.
0

majith basha
Top achievements
Rank 1
answered on 05 Oct 2010, 11:19 AM
Hi Princy,
The above code is clear. My Question is Can we get (GridFooterItem and GridDataItem) in the single loop.
1. The problem is I am doing the calculation in client side. I need to get Footer Item(Client ID) of the corresponding Grid data item which is being Updated.
I am trying the below code but unable to perform this.
The above code is clear. My Question is Can we get (GridFooterItem and GridDataItem) in the single loop.
1. The problem is I am doing the calculation in client side. I need to get Footer Item(Client ID) of the corresponding Grid data item which is being Updated.
I am trying the below code but unable to perform this.
if
(e.Item
is
GridFooterItem && e.Item.OwnerTableView.Name ==
"Detail"
)
{
GridFooterItem footer = (GridFooterItem)e.Item;
(footer[
"Template1"
].FindControl(
"TextBox2"
)
as
TextBox).Text = sum.ToString();
clientID = (footer[
"Template1"
].FindControl(
"TextBox2"
)
as
TextBox).ClientID;
foreach
(GridDataItem gdi
in
RadGrid1.Items)
{
if
(gdi.ChildItem !=
null
)
{
for
(
int
i = 0; i < gdi.ChildItem.NestedTableViews[0].Items.Count; i++)
{
GridDataItem dataItem = gdi.ChildItem.NestedTableViews[0].Items[i];
TextBox qTextBox = dataItem.FindControl(
"TextBox1"
)
as
TextBox;
TextBox uTextBox = dataItem.FindControl(
"TextBox3"
)
as
TextBox;
Label lblCM = dataItem.FindControl(
"lblCM"
)
as
Label;
Label lblTotal = dataItem.FindControl(
"lblTotal"
)
as
Label;
if
(qTextBox !=
null
&& uTextBox !=
null
&& lblCMI !=
null
&& lblTotalCMI !=
null
)
{
(dataItem[
"Template1"
].FindControl(
"TextBox1"
)
as
TextBox).Attributes.Add(
"onblur"
,
"update('"
+ lblCM.ClientID +
"'"
+
","
+
"'"
+ lblTotal.ClientID +
"'"
+
","
+
"'"
+ uTextBox.ClientID +
"'"
+
","
+
"'"
+ clientID +
"'"
+
","
+
"'"
+ (dataItem[
"Template1"
].FindControl(
"TextBox1"
)
as
TextBox).ClientID +
"')"
);
(dataItem[
"Template1"
].FindControl(
"TextBox1"
)
as
TextBox).Attributes.Add(
"onfocus"
,
"getInitialValue('"
+ (dataItem[
"Template1"
].FindControl(
"TextBox1"
)
as
TextBox).ClientID +
"')"
);
}
}
}
}
}
Thanks in advance.
MAJITH.B
0

MBEN
Top achievements
Rank 2
Veteran
answered on 29 May 2014, 06:28 PM
I have a similar scenario. My grid is rendered in edit mode.
I have a read only textbox in footer which displays the total of each rows. I am doing a client side validation that the total does not exceed 100. For that I need to hook up the client id of the textbox in the footer in my griddataitem loop.
How can i do this?
I have a read only textbox in footer which displays the total of each rows. I am doing a client side validation that the total does not exceed 100. For that I need to hook up the client id of the textbox in the footer in my griddataitem loop.
How can i do this?
0

Princy
Top achievements
Rank 2
answered on 30 May 2014, 08:46 AM
Hi MBEN,
Please try the below JavaScript code snippet to access the TextBox in the GridFooterItem.
JavaScript:
Thanks,
Princy.
Please try the below JavaScript code snippet to access the TextBox in the GridFooterItem.
JavaScript:
var
footerTextBox =
'<%=(GridFooterItem)RadGrid1.MasterTableView.GetItems(GridItemType.Footer)[0]).FindControl("RadTextBox1").ClientID %>'
;
var
TextBox = document.getElementById(footerTextBox);
Thanks,
Princy.