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

RadFileExplorer with custom button column

3 Answers 127 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
CSharp
Top achievements
Rank 1
CSharp asked on 30 Dec 2009, 11:42 AM
i try add custom button column as descripted in demo like:
private void AddGridButtonColumn(string name, string uniqueName, bool sortable)  
        {  
            //remove first if grid has a column with that name  
            RemoveGridColumn(uniqueName);  
            // Add a new column with the specified name  
            GridButtonColumn gridButtonColumn1 = new GridButtonColumn();  
            gridButtonColumn1.HeaderText = name;  
            if (sortable)  
                gridButtonColumn1.SortExpression = uniqueName;  
            gridButtonColumn1.UniqueName = uniqueName;  
            gridButtonColumn1.DataTextField = uniqueName;  
 
            RadFileExplorer_SharedFolderBrowser.Grid.Columns.Add(gridButtonColumn1);  
        } 

but no button appears in grid.

any solution?

3 Answers, 1 is accepted

Sort by
0
Fiko
Telerik team
answered on 04 Jan 2010, 02:06 PM
Hello CSharp,

I see that you use this demo as base for your code, but I need to examine your full code in order to provide a solution. Could you please open a new support ticket and send me a runnable project that shows your approach and I will rework it in order to make it to work.


Sincerely yours,
Fiko
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ken
Top achievements
Rank 1
answered on 20 Jan 2013, 04:15 PM
I too am trying to get a GridButtonColumn to display in the grid.. none of the examples show a button. All seems to work ok except no button visible
GridButtonColumn gridButtonColumn1 = new GridButtonColumn();
gridButtonColumn1.HeaderText = "View";
gridButtonColumn1.Text = "View";
gridButtonColumn1.Visible = true;
gridButtonColumn1.UniqueName = "View";
RadFileExplorer1.Grid.Columns.Add(gridButtonColumn1);
0
Vessy
Telerik team
answered on 04 Feb 2013, 07:03 PM
Hi Ken,

I have already answered your support ticket on the subject, but for convenience I am pasting my answer here as well:

The FileExplore does not allow you to add directly a GridButtonColumn, but you could use the approach shown in this article and add an <input type="button" instead of an <img>. You can directly attach a JavaScript handler to the buttons in order to apply the desired functionality:

in the content provider:

public override DirectoryItem ResolveDirectory(string path)
{
    DirectoryItem oldItem = base.ResolveDirectory(path);
    foreach (FileItem fileItem in oldItem.Files)
    {
        string htmlText = string.Format("<input type='button' value='{0}' onclick='onClickHandler(this);' />", "click me");
        fileItem.Attributes.Add("Button", htmlText);
    }
    return oldItem;
}

The implementation of the  onClickHandler:
<script type="text/javascript">
    function onClickHandler(button) {
        alert("Clicked");
        // your logic
    }
</script>

For your convenience I am attaching a sample project demonstrating the approach.

Regards,
Vesi
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.
Tags
FileExplorer
Asked by
CSharp
Top achievements
Rank 1
Answers by
Fiko
Telerik team
Ken
Top achievements
Rank 1
Vessy
Telerik team
Share this question
or