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

How do you add an upload control in each row of a grid

1 Answer 375 Views
Upload
This is a migrated thread and some comments may be shown as answers.
StevenDale
Top achievements
Rank 2
StevenDale asked on 19 Jun 2013, 01:43 AM
Do you have any examples of having a upload control in each row of a grid used in the following way:

@(Html.Kendo().Grid<RepairModel>()
.Name("RepairGrid_#=Id#")
.ToolBar(toolBar => toolBar.Create())
.Columns(columns =>
{
columns.ForeignKey(e => e.Type, (System.Collections.IEnumerable)ViewData["RepairTypes"], "Id", "Name")
.Title("Type");
columns.Bound(r => r.Cost);
columns.Bound(r => r.RepairDate);
columns.Bound(r => r.Description);
columns.Bound(r => r.Mileage);
columns.Bound(r => r.RepairLocation);
columns.Command(commands =>
{
commands.Edit().Text("Edit");
commands.Destroy().Text("Delete");
}).Title("Actions");
})
.DataSource(dataSource => dataSource
.Ajax()
.Events(events => events.Error("grid_error"))
.ServerOperation(false)
.PageSize(100)
.Read(read => read.Action("GetRepairs", "Equipment", new { equipmentId = "#=Id#" }))
.Create(create => create.Action("CreateRepair", "Equipment", new { equipmentId = "#=Id#" }))
.Update("UpdateRepair", "Equipment")
.Destroy("DestroyRepair", "Equipment")
//.Group(g => g.Add(gi => gi.Type))
.Sort(g =>
{
g.Add(gi => gi.Type);
g.Add(gi => gi.RepairDate);
})
.Model(model =>
{
model.Id(m => m.Equipment);
model.Field(m => m.Id).DefaultValue(new Guid());
model.Field(m => m.Equipment).DefaultValue(new Guid());
model.Field(m => m.Type).Editable(true).DefaultValue(((List<RepairTypeModel>)ViewData["RepairTypes"]).Any() ? ((List<RepairTypeModel>)ViewData["RepairTypes"])[0].Id : Guid.Empty);
})
)
.Pageable()
.Sortable()
.Groupable()
.ToClientTemplate())

Thanks,

Billy Jacobs

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 20 Jun 2013, 03:26 PM
Hello Billy,

How to put a Kendo widget inside the template of a column is covered multiple times on the forums. Check the following example to get the idea:

http://jsbin.com/oletef/7

Basically you put an input element (of type file) element inside the template which you later initialize and turn into upload when the dataBound event of the Grid is triggered.

dataBound:function(){
                        var grid = this;
                        $(".upload").each(function(){
                          var chart = $(this);
                          var tr = chart.closest('tr');
                          var model = grid.dataItem(tr);
                          chart.kendoUpload({ ...options }
                        });
 
}


Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Upload
Asked by
StevenDale
Top achievements
Rank 2
Answers by
Petur Subev
Telerik team
Share this question
or