This is a migrated thread and some comments may be shown as answers.

Get values of custom fields from Javascript?

2 Answers 86 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Markús
Top achievements
Rank 1
Markús asked on 21 Nov 2011, 07:59 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Dobromir
Telerik team
answered on 23 Nov 2011, 12:39 PM
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
0
Markús
Top achievements
Rank 1
answered on 23 Nov 2011, 04:26 PM
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);
Tags
FileExplorer
Asked by
Markús
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Markús
Top achievements
Rank 1
Share this question
or