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

Uplod in Grid

10 Answers 181 Views
Upload
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Michael
Top achievements
Rank 1
Michael asked on 01 Mar 2011, 07:28 PM

Hello,

Are there any examples of using the upload control in the grid?  I'm basically looking for functionality that I can use to upload a file, and then view the file after I upload it.

Sort of like the example of the rad upload in ajax grid:

http://demos.telerik.com/aspnet-ajax/controls/examples/integration/raduploadinajaxifiedgrid/defaultcs.aspx?product=upload


Thanks for any help.

10 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 02 Mar 2011, 02:58 PM
Hi Michael,

I've uploaded a code library that demonstrates how to use the Upload in Grid.
http://www.telerik.com/community/code-library/aspnet-mvc/upload/upload-in-grid.aspx

I hope this helps.

Best Regards,
Tsvetomir Tsonev
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Giedrius
Top achievements
Rank 1
answered on 23 May 2011, 09:53 AM
Hi,
I've updated given sample with insert functionality and can't get it to work:
[HttpPost]
       [GridAction]
       public ActionResult Insert()
       {
           var newModel = new Employee();
           TryUpdateModel(newModel);
 
           Model = new List<Employee>
                       {
                           Model.First(),
                           newModel
                       };
 
           return View(new GridModel(Model));
       }
Attachment:
function onUpload(e) {
    if (getDataItem(this) !== undefined) {
        e.data = { id: getDataItem(this).ID };
    } else {
        e.data = { id: 0 };
    }
}
View:
@(Html.Telerik().Grid<Employee>()
    .Name("Grid")
    .DataKeys(keys => keys.Add("ID"))
    .ToolBar(x=>x.Insert())
    .Columns(columns =>
    {
        columns.Bound(c => c.Picture)
            .ClientTemplate("<img src='/Content/UserFiles/<#= Picture #>' alt='<#= Name #>' />")
            .Width(200)
            .Title("Picture");
        columns.Bound(c => c.Name);
        columns.Command(c => c.Edit()).Width(200);
    })
    .DataBinding(dataBinding => dataBinding.Ajax()
        .Select("Select", "Home")
        .Update("Update", "Home")
        .Insert("Insert", "Home")
    )
)

So several things:
1) looks like I can't access getDataItem(this) when inserting, is this by design?
2) When inserting I'm getting error "Error! Upload failed. Unexpected server response - see console." File is actually uploaded, in console i see folowing:
Server response: {"fileName":"Chrysanthemum.jpg"}.
0
Giedrius
Top achievements
Rank 1
answered on 25 May 2011, 12:49 PM
Just wondering, was my problem unclear, or is it real issue and it will take some time to find solution?
0
T. Tsonev
Telerik team
answered on 26 May 2011, 07:54 AM
Hi Michael,

We've updated the code library to include insert functionality. I hope this helps.

All the best,
Tsvetomir Tsonev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Martin
Top achievements
Rank 1
answered on 23 Jun 2011, 09:44 PM
Hi, 
Does upload in grid work with MVC3? 
Despite applying '[UIHint("Attachment")]' annotation in my ViewModel, during editing/inserting there is no Upload button, just regular textbox.  Have I omitted something? 

When I had moved necessary files to code library project (MVC2)  it worked at once.  
0
Giedrius
Top achievements
Rank 1
answered on 27 Jun 2011, 07:08 AM
Yes, it does work on MVC3, I'm using in my project.
Btw, thanks Tsvetomir for updated example.
0
Alejandro
Top achievements
Rank 1
answered on 07 Sep 2011, 02:23 AM
I having the same problem uploading documents within an insert row scenario.... (it works for updates). I have a more recent version compared to the one you suggest to download... mine is MVC_2011_2_712-OpenSource using MVC 3. Is this bug already fixed for this version? Should I download the 2011.1.414 instead (I see the name of the file is UploadGridIntegration-MVC2.zip.... so I guess that download is just for MVC 2).

Let me know if there is any fix otherwise I would appreciate if you have a simple sample illustrating the upload functionaly working upon inserts (and updates) with MVC3... (and razor if possible).

Cheers
/Alejandro
0
T. Tsonev
Telerik team
answered on 07 Sep 2011, 04:22 PM
Hello Alejandro,

We've downgraded the project to MVC2 in order to lower the requirements for running it. It does not use anything MVC3-specific so upgrading should be trivial.

The code from the code library will work with the Q2 version as well.

I hope this clears things up.

Kind regards,
Tsvetomir Tsonev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Alejandro
Top achievements
Rank 1
answered on 09 Sep 2011, 02:29 AM
Thanks Tsvetomir

My mistake, I had problems with the action method parameter. I changed it to nullable (Guid?) and now I get the Ajax OnSave call correctly when a file is uploaded... However, while having uploaded a file I am having problems with the TryUpdateModel() in the Insert method. The behaviour is exactly the same as the one described here "http://www.telerik.com/community/forums/aspnet-mvc/upload/upload-control-conflicts-with-updatemodel-mvc-method.aspx"... If I remove the file (by click on the "remove" button and try to insert the row again (this time without the attachment) then the TryUpdateModel() does work (same if I never attach a file).

I see there is a bug fix for this conflict with TryUpdateModel on version 2011.1.419... .however, my version is MVC_2011_2_712-OpenSource using MVC 3... Do you know if that hot-fix was merged on time when the 2011.2.712 version?

Regards
/Alejandro
0
Alejandro
Top achievements
Rank 1
answered on 09 Sep 2011, 03:26 AM

Hi again Tsvetomir

I found and tried the 295848_Telerik-Extensions-for-ASPNET-MVC-2011-2-829-hotfix version (more recent than 2011.2.712 and 2011.1.419) and now everything works.  I guess there were some UpLoad fixes recently.

Best regards.
Tags
Upload
Asked by
Michael
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Giedrius
Top achievements
Rank 1
Martin
Top achievements
Rank 1
Alejandro
Top achievements
Rank 1
Share this question
or