Stuart Hemming
Top achievements
Rank 2
Stuart Hemming
asked on 08 Nov 2010, 06:26 PM
See the grid ...
See the JavaScript ...
See my confused face when running the page and getting a zero back as result of nestedViews().length for each row.
What I actually want to be able to do is get at the controls inside the nestedView for a given row on RowClick. But I've rather fallen at the first fence.
--
Stuart
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AutoGenerateColumns
=
"false"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
>
<
MasterTableView
HierarchyLoadMode
=
"Client"
ClientDataKeyNames
=
"LastName, FirstName, Age"
>
<
Columns
>
<
telerik:GridBoundColumn
UniqueName
=
"Col1"
DataField
=
"LastName"
/>
<
telerik:GridBoundColumn
UniqueName
=
"Col2"
DataField
=
"FirstName"
/>
</
Columns
>
<
NestedViewTemplate
>
<
telerik:RadTextBox
ID
=
"txtAge"
runat
=
"server"
Label
=
"Age:"
Text='<%# Bind("Age") %>' />
<
telerik:RadTextBox
ID
=
"txtSex"
runat
=
"server"
Label
=
"Age:"
Text='<%# Bind("Sex") %>' />
</
NestedViewTemplate
>
</
MasterTableView
>
<
ClientSettings
>
<
Selecting
AllowRowSelect
=
"true"
/>
<
ClientEvents
OnRowSelected
=
"GridRowSelected"
OnRowCreated
=
"GridRowCreated"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
See the JavaScript ...
function
GridRowCreated(sender, e) {
var
x = e.get_gridDataItem();
alert(x.get_nestedViews().length);
}
See my confused face when running the page and getting a zero back as result of nestedViews().length for each row.
What I actually want to be able to do is get at the controls inside the nestedView for a given row on RowClick. But I've rather fallen at the first fence.
--
Stuart
10 Answers, 1 is accepted
0
Stuart Hemming
Top achievements
Rank 2
answered on 09 Nov 2010, 10:20 AM
In the cold light of day I realise that the reason I can't see the nestedViews at this point is 'cos they prolly haven't been created yet.
However, I can't see them when I handle the RowClicked event either.
--
Stuart
However, I can't see them when I handle the RowClicked event either.
--
Stuart
0
Hi Stuart,
You could try using the OnHierarchyExpanded client-side event of RadGrid in order to access the needed objects, since it guarantees that the hierarchy has been expanded just before it was fired.
Greetings,
Tsvetina
the Telerik team
You could try using the OnHierarchyExpanded client-side event of RadGrid in order to access the needed objects, since it guarantees that the hierarchy has been expanded just before it was fired.
Greetings,
Tsvetina
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Stuart Hemming
Top achievements
Rank 2
answered on 10 Nov 2010, 12:41 PM
Hey there Tsvetina,
Does this mean that I can't access the nestedView in the OnRowClick client event? Event if I have HierarchyLoadMode == Client?
--
Stuart
Does this mean that I can't access the nestedView in the OnRowClick client event? Event if I have HierarchyLoadMode == Client?
--
Stuart
0
Stuart Hemming
Top achievements
Rank 2
answered on 10 Nov 2010, 12:55 PM
And I assume I can get at the controls in the nestedView using something like this ...
(I'm handling OnRowCreated, so I have access to get_gridDataItem())
Yes?
--
Stuart
function
HierarchyExpanding(sender, e) {
var
nestedView = e.get_gridDataItem().get_nestedViews();
var
o = $telerik.findControl(nestedView,
"IDofControlToFind"
);
}
(I'm handling OnRowCreated, so I have access to get_gridDataItem())
Yes?
--
Stuart
0
Stuart Hemming
Top achievements
Rank 2
answered on 10 Nov 2010, 03:13 PM
Tried this ...
And nestedView is always null, even when, clearly, it isn't.
--
Stuart
function
HierarchyExpanded(sender, e) {
var
nestedView = e.get_gridDataItem().get_nestedViews();
}
And nestedView is always null, even when, clearly, it isn't.
--
Stuart
0
Hi Stuart,
The important part here is that get_nestedViews() returns a collection of client-side objects of type GridTableView (what the templated nested view is not). That is why this property returns null. A possible way to access the nested view created from template is to take its DOM element from the OnHierarchyExpanded event arguments:
Greetings,
Tsvetina
the Telerik team
The important part here is that get_nestedViews() returns a collection of client-side objects of type GridTableView (what the templated nested view is not). That is why this property returns null. A possible way to access the nested view created from template is to take its DOM element from the OnHierarchyExpanded event arguments:
function
GridHierarchyExpanded(sender, e) {
var
x = e.get_nestedViewItem();
}
Greetings,
Tsvetina
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Stuart Hemming
Top achievements
Rank 2
answered on 12 Nov 2010, 10:29 PM
Tsvetina,
Thanks for that. That gets me closer than I was.
> what the templated nested view is not
You're got to understand the confusion though, yes? After all it's called a templated nested view, right?
So, e.get_nestedViewItem returns the <TR> that contains the <TD> that contains the templated item.
So, I thought that at that point I should be able to plug that in to a call to $telerik.findControl, but it seems not, or at least, it's not that straightforward, is it?
What I mean is, calling for example,
is always going to return null, cos the rendered HTML sets the label's ID to something like "RadGrid1_ctl00_ctl06_lblFirstName".
So, having found my nestedView that isn't a nestedView, how do I get a reference to an object inside the object? I can't use the usual technique of calling <% = lblFirstName.ClientID %>.
I know that I'm not the brightest button in the box, but this seems difficult, even by my standards.
--
Stuart
Thanks for that. That gets me closer than I was.
> what the templated nested view is not
You're got to understand the confusion though, yes? After all it's called a templated nested view, right?
So, e.get_nestedViewItem returns the <TR> that contains the <TD> that contains the templated item.
So, I thought that at that point I should be able to plug that in to a call to $telerik.findControl, but it seems not, or at least, it's not that straightforward, is it?
What I mean is, calling for example,
var
o = $telerik.findControl(x,
"lblFirstName"
);
is always going to return null, cos the rendered HTML sets the label's ID to something like "RadGrid1_ctl00_ctl06_lblFirstName".
So, having found my nestedView that isn't a nestedView, how do I get a reference to an object inside the object? I can't use the usual technique of calling <% = lblFirstName.ClientID %>.
I know that I'm not the brightest button in the box, but this seems difficult, even by my standards.
--
Stuart
0
Hi Stuart,
You could try using $find or $get (depending on the type of control you need to access) to get hold of the control in the nested view, where you should pass the DOM element returned by get_nestedViewItem() as a second argument.
Kind regards,
Tsvetina
the Telerik team
You could try using $find or $get (depending on the type of control you need to access) to get hold of the control in the nested view, where you should pass the DOM element returned by get_nestedViewItem() as a second argument.
Kind regards,
Tsvetina
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Stuart Hemming
Top achievements
Rank 2
answered on 20 Nov 2010, 07:52 AM
Hi Tsvetina,
I take your point about $get/$find, but I'm still left with the same issue wrt the ID of the item to get aren't I?
--
Stuart
I take your point about $get/$find, but I'm still left with the same issue wrt the ID of the item to get aren't I?
--
Stuart
0
Hello Stuart,
Yes, since your hierarchy is loaded on the client, it gets more complicated to find the client ids (otherwise you could have stored them somewhere in the page on postback). In this scenario you can only search for the controls by tag name and id of the given tag, like it is done in the client edit with batch server update demo in the HideEditor() javascript method. For code sample on accessing some RadControls in the client edit scenario, you can also take a look at this forum thread.
Regards,
Tsvetina
the Telerik team
Yes, since your hierarchy is loaded on the client, it gets more complicated to find the client ids (otherwise you could have stored them somewhere in the page on postback). In this scenario you can only search for the controls by tag name and id of the given tag, like it is done in the client edit with batch server update demo in the HideEditor() javascript method. For code sample on accessing some RadControls in the client edit scenario, you can also take a look at this forum thread.
Regards,
Tsvetina
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.