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

How can i add selected files in grid using RadAsyncUpload

3 Answers 149 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Jagadeeswararao
Top achievements
Rank 1
Jagadeeswararao asked on 23 Sep 2013, 09:53 AM
I have a requirement that, when  selected(RadAsyncUpload) a file, the file details should be populated in grid on the same window. how can i implement.
File details like : size , name , path.

Please help me

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 24 Sep 2013, 09:33 AM
Hi Jagadeeswararao,

Please take a look into the following code snippet I tried to display the selected file name and size in the client side. Due to some Browser restrictionit is not possible to  access the path of the selected file in RadAsyncUpload.

ASPX:
<telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" TargetFolder="Uploads"
    OnClientProgressUpdating="OnClientProgressUpdating">
</telerik:RadAsyncUpload>
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="false" AutoGenerateColumns="false"
    CssClass="grid">
    <MasterTableView>
        <Columns>
            <telerik:GridBoundColumn DataField="FileName" HeaderText="ID">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="FileSize" HeaderText="Text">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
    <ClientSettings>
        <ClientEvents OnCommand="function(){}" />
    </ClientSettings>
</telerik:RadGrid>

JavaScript:
<script type="text/javascript">
    var data = new Array();
    function OnClientProgressUpdating(sender, args) {
        var filename = args.get_data().fileName; // selected file name
        var filesize = args.get_data().fileSize; //selected file size
        data = [{ "FileName": filename, "FileSize": filesize}];
        $find("RadGrid1").removeCssClass("grid");
        $find("RadGrid1").addCssClass("grid1");
        var grid = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
        grid.set_dataSource(data); //adding file name and size into grid
        grid.dataBind();
    }
</script>

CSS:
<style type="text/css">
    .grid
    {
        display : none !important;
    }
    .grid1
    {
        display : block !important;
    }
</style>

Thanks,
Shinu.
0
Jagadeeswararao
Top achievements
Rank 1
answered on 25 Sep 2013, 07:44 AM
Hi Shinu,
 Thanks for responding early. I tried that code which you posted but the data(size and Name) was not populated in the Grid.
  can't find what the issue exactly.

Thanks,
Jagadeeswararao
0
Shinu
Top achievements
Rank 2
answered on 25 Sep 2013, 08:46 AM
Hi Jagadeeswararao,

Unfortunately I couldn't replicate the issue. The above code is working fine at my end. Please provide your code so that I can help you further.

Thanks,
Shinu.
Tags
AsyncUpload
Asked by
Jagadeeswararao
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jagadeeswararao
Top achievements
Rank 1
Share this question
or