Get values of custom fields from Javascript?

3 posts, 1 answers
  1. Markús
    Markús avatar
    3 posts
    Member since:
    Nov 2010

    Posted 21 Nov 2011 Link to this post

    Is it possible to fetch the values of a custom field from a Javascript in a RadFileExplorer?
    I have successfully implemenented a custom content provider, but I need to get the values from the custom fields

    I tried the code below, but I get no results.

    function OnItemSelected(sender, args) {
     
        var fexplorer = $find("<%=FileExplorer.ClientID %>");
        var txtDocumentDescription = $find("<%=TxtActionDocumentDescription.ClientID %>");
     
        // find the description from custom fields to set it
        var grid = fexplorer.get_grid();
        var gridSelectedItems = grid.get_selectedItems();
        var gridSelectedItem = gridSelectedItems[0];
        var description = gridSelectedItem.get_dataItem()["Description"];
        txtDocumentDescription.set_value(description);
    }
  2. Answer
    Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 23 Nov 2011 Link to this post

    Hi Markús,

    I have already answered your support ticket on the subject. For convenience I will paste my answer here as well.

    I am not sure why the provided sample code is not working on your side. To access the data in the browser, you need to use the grid object in the file explorer (as you have done). Could you please verify that the custom column is correctly populated? Also, are there any JavaScript errors thrown on the page when executing the OnItemSelected function?

    For your convenience I have attached a sample page implementing the required functionality, could you please modify it to a point where the problem occurs and send it back so we can investigate the issue further?


    Best wishes,
    Dobromir
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Markús
    Markús avatar
    3 posts
    Member since:
    Nov 2010

    Posted 23 Nov 2011 Link to this post

    I did some changes in accordance with the example, then it worked well. The "Attributes" property was what I was missing.

    I modified my code excerpt to look like this:

    // find the description from custom fields to set it
    var gridSelectedItem = fexplorer.get_grid().get_masterTableView().get_selectedItems()[0];
    var description = gridSelectedItem.get_dataItem().Attributes["Description"];
    txtDocumentDescription.set_value(description);
Back to Top