问题
I want to obtain the value of a hidden control, that is a TreeListBoundColumn
of a TreeList:
<telerik:RadTreeList ID="rtlRshItems" ...>
<Columns>
<telerik:TreeListBoundColumn DataField="FtcPrevious"
UniqueName="FtcPrevious" Visible="false" runat="server">
</telerik:TreeListBoundColumn>
</Columns>
</telerik:RadTreeList>
This is what I have coded but does not work (although it comes from Telerik's forums)
// Calculate the new FTC
var treeList = $find("<%= rtlRshItems.ClientID %>");
var ftcPrevious = treeList.get_items().getItem(0).findControl("FtcPrevious");
var ftcPreviousValue = ftcPrevious.value;
回答1:
It would probably be easier to utilize ClientDataKeyNames
and get_dataKeyValue()
instead of trying to hide a column.
Change the definition of the RadTreeList control to something like:
<telerik:RadTreeList ID="rtlRshItems" ClientDataKeyNames="FtcPrevious" ...>
<Columns>
</Columns>
</telerik:RadTreeList>
Adjust your Javascript:
var treeList = $find("<%= rtlRshItems.ClientID %>");
var ftcPreviousValue = treeList.getItem(0).get_dataKeyValue("FtcPrevious");
Note: The most recent Telerik documentation for RadTreeList does not list get_items()
as a valid function call. Adjust as needed for your version.
回答2:
First, I would recommend setting the Display="false" attribute on the telerik:TreeListBoundColumn element rather than Visible="false". I believe this may be the culprit.
Second, have you tried using getColumnByUniqueName() client-side function:
var treeList = $find("<%= rtlRshItems.ClientID %>");
var ftcPrevious = treeList.getColumnByUniqueName("FtcPrevious");
来源:https://stackoverflow.com/questions/9523733/telerik-asp-net-ajax-how-to-get-value-of-a-data-bound-column-client-side