javal patel
Top achievements
Rank 1
javal patel
asked on 03 Aug 2013, 04:59 PM
hi
i have some specific requiremnet for client... i have to diplay company name on top of ther page and detail in below portion.
i use normal html control on top page and Kendo grid in detail portion. but i don't know how to pass whole model on controller on save.
my model is like below...
public class Company
{
public string Company { get; set; }
public IEnumerable<Person> Clients { get; set; }
}
public class Person
{
[UIHint("Integer")]
public int PersonID { get; set; }
[Required]
public string Name { get; set; }
}
on view page i declare model like this
@model MyData.Company
////////
//
@using (Html.BeginForm())
{
@Html.EditorFor(x => x.Company);
////
Kendo grid
@(
Html.kenogrid(Model.Person)///////
can you please help me or give sample working application based on my this model.
it will vary help full me to develop my mvc application with this control
thanks
i have some specific requiremnet for client... i have to diplay company name on top of ther page and detail in below portion.
i use normal html control on top page and Kendo grid in detail portion. but i don't know how to pass whole model on controller on save.
my model is like below...
public class Company
{
public string Company { get; set; }
public IEnumerable<Person> Clients { get; set; }
}
public class Person
{
[UIHint("Integer")]
public int PersonID { get; set; }
[Required]
public string Name { get; set; }
}
on view page i declare model like this
@model MyData.Company
////////
//
@using (Html.BeginForm())
{
@Html.EditorFor(x => x.Company);
////
Kendo grid
@(
Html.kenogrid(Model.Person)///////
can you please help me or give sample working application based on my this model.
it will vary help full me to develop my mvc application with this control
thanks
4 Answers, 1 is accepted
0
Hello,
Daniel
Telerik
We have a code-library that demonstrates how the Grid data can be submitted with a form along with the other inputs. Please check it on this page.
Regards,Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
javal patel
Top achievements
Rank 1
answered on 07 Aug 2013, 09:29 AM
hi Daniel ,
i tried your suggested code and implement in my page it's solve my half problem.but some mode help need from tour side.
i have Drop down list in batch grid . when i edit it will populate control and after selecting it will display selected code. i think without client template it will work fine it display text and in back ground it will maintain id.and in save it will pass id.
but in this case it will display id and also maintain id. i want text should display and id should maintain.
i have attached screen shot so you will get better idea
below is my batch update grid code
@(Html.Kendo().Grid(Model.OFreightOrderDetailsView)
.Name("OrderDetails")
.ToolBar(tools => tools.Create().Text("Add"))
.Editable(editable => editable.Mode(GridEditMode.InCell).CreateAt(GridInsertRowPosition.Bottom))
.Columns(columns =>
{
columns.ForeignKey(p => p.cAction, (System.Collections.IEnumerable)ViewData["ActionType"], "Value", "Name").ClientTemplate("#= cAction #" +
"<input type='hidden' name='OFreightOrderDetailsView[#= index(data)#].cAction' value='#= cAction #' />"
);
columns.ForeignKey(p => p.cProductId, (System.Collections.IEnumerable)ViewData["FuelTypeList"], "Cid", "Ccode").ClientTemplate("#= cProductId #" +
"<input type='hidden' name='OFreightOrderDetailsView[#= index(data)#].cProductId' value='#= cProductId #' />"
);
columns.ForeignKey(p => p.cTerminalId, (System.Collections.IEnumerable)ViewData["TerminalList"], "Cid", "Ccode");
columns.Bound(p => p.nQuantity).Format("{0:n0}").Width(100).ClientTemplate("#= nQuantity #" +
" <input type='hidden' name='OFreightOrderDetailsView[#= index(data)#].nQuantity' value='#= nQuantity #' />"
);
columns.Bound(p => p.cDate).Format("{0:dd.MM.yyyy}").Width(200).ClientTemplate("#= cDate #" +
"<input type='hidden' name='OFreightOrderDetailsView[#= index(data)#].cDate' value='#= cDate #' />"
);
columns.Bound(p => p.cTime).Format("{0:h:mm:ss}").Width(100).ClientTemplate("#= cTime #" +
"<input type='hidden' name='OFreightOrderDetailsView[#= index(data)#].cTime' value='#= cTime #' />"
);
columns.Command(command => command.Destroy()).Width(100);
})
.DataSource(dataSource => dataSource.Ajax()
.Model(model =>
{
model.Id(p => p.Cid);
})
.ServerOperation(false)
)
)
i hope this information is help full to you for my problem.
if you find any problem for this you can tell me .. i will provide more in formation.
i am now in Do or Die situation to pickup this control... please help me as soon as problem.
thanks.
i tried your suggested code and implement in my page it's solve my half problem.but some mode help need from tour side.
i have Drop down list in batch grid . when i edit it will populate control and after selecting it will display selected code. i think without client template it will work fine it display text and in back ground it will maintain id.and in save it will pass id.
but in this case it will display id and also maintain id. i want text should display and id should maintain.
i have attached screen shot so you will get better idea
below is my batch update grid code
@(Html.Kendo().Grid(Model.OFreightOrderDetailsView)
.Name("OrderDetails")
.ToolBar(tools => tools.Create().Text("Add"))
.Editable(editable => editable.Mode(GridEditMode.InCell).CreateAt(GridInsertRowPosition.Bottom))
.Columns(columns =>
{
columns.ForeignKey(p => p.cAction, (System.Collections.IEnumerable)ViewData["ActionType"], "Value", "Name").ClientTemplate("#= cAction #" +
"<input type='hidden' name='OFreightOrderDetailsView[#= index(data)#].cAction' value='#= cAction #' />"
);
columns.ForeignKey(p => p.cProductId, (System.Collections.IEnumerable)ViewData["FuelTypeList"], "Cid", "Ccode").ClientTemplate("#= cProductId #" +
"<input type='hidden' name='OFreightOrderDetailsView[#= index(data)#].cProductId' value='#= cProductId #' />"
);
columns.ForeignKey(p => p.cTerminalId, (System.Collections.IEnumerable)ViewData["TerminalList"], "Cid", "Ccode");
columns.Bound(p => p.nQuantity).Format("{0:n0}").Width(100).ClientTemplate("#= nQuantity #" +
" <input type='hidden' name='OFreightOrderDetailsView[#= index(data)#].nQuantity' value='#= nQuantity #' />"
);
columns.Bound(p => p.cDate).Format("{0:dd.MM.yyyy}").Width(200).ClientTemplate("#= cDate #" +
"<input type='hidden' name='OFreightOrderDetailsView[#= index(data)#].cDate' value='#= cDate #' />"
);
columns.Bound(p => p.cTime).Format("{0:h:mm:ss}").Width(100).ClientTemplate("#= cTime #" +
"<input type='hidden' name='OFreightOrderDetailsView[#= index(data)#].cTime' value='#= cTime #' />"
);
columns.Command(command => command.Destroy()).Width(100);
})
.DataSource(dataSource => dataSource.Ajax()
.Model(model =>
{
model.Id(p => p.Cid);
})
.ServerOperation(false)
)
)
i hope this information is help full to you for my problem.
if you find any problem for this you can tell me .. i will provide more in formation.
i am now in Do or Die situation to pickup this control... please help me as soon as problem.
thanks.
0
Hello again,
Regards,
Daniel
Telerik
If a foreignkey column is used then you should map the values with custom code since by default this is performed in the template. You could use the following approach in order to achieve this:
columns.ForeignKey(p => p.cAction, (System.Collections.IEnumerable)ViewData["ActionType"], "Value", "Name").ClientTemplate("#= foreignValues[cAction] #" +
"<
input
type
=
'hidden'
name
=
'OFreightOrderDetailsView[#= index(data)#].cAction'
value
=
'#= cAction #'
/>"
);
<
script
type
=
"text/javascript"
>
var foreignData = @(Html.Raw(Json.Encode(ViewData["ActionType"]))),
foreignValues = {};
for (var i = 0; i <
foreignData.length
; i++) {
foreignValues[foreignData[i].Value] = foreignData[i].Name;
}
</script>
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
javal patel
Top achievements
Rank 1
answered on 09 Aug 2013, 12:24 PM
hi Daniel ,
Thank's for your solution.
IT'S WORK Perfectly !!!!!
Thank's for your solution.
IT'S WORK Perfectly !!!!!