Telerik ASP.NET AJAX: How to get value of a data bound column, client-side

北城余情 提交于 2019-12-25 05:36:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!