Hello ,
I have a kendoGrid in form with different clientTemplate like this :
@using (Ajax.BeginForm("edition","activites",null,new { id = id + "formSaisieHeures", width = "100%" })) { @(Html.Kendo().Grid<Integraal.Models.Activite>() .Name(id+"GrilleSaisieHeures") .Columns(columns => { columns.Bound(p => p.rowId) .ClientTemplate("#= rowId #" + "<input type='hidden' name='Activites[#= index(data)#].rowId' value='#= rowId #' />") .Hidden(); columns.Bound(p => p.date) .ClientTemplate("#= kendo.toString(date,'d') #" + "<input type='hidden' name='Activites[#= index(data)#].date' value='#= kendo.toString(date,'dd/MM/yyyy') #' />") .Width(100); columns.Bound(p => p.client.code) .ClientTemplate("#= client.code #" + "<input type='hidden' name='Activites[#= index(data)#].client.code' value='#= client.code #' />") .Width(100); columns.Bound(p => p.client.raisonSociale) .ClientTemplate("#= client.raisonSociale #" + "<input type='hidden' name='Activites[#= index(data)#].client.raisonSociale' value='#= client.raisonSociale #' />") .Width(150); columns.Bound(p => p.affaire.code) .ClientTemplate("#= affaire.code #" + "<input type='hidden' name='Activites[#= index(data)#].affaire.code' value='#= affaire.code #' />") .Width(100); columns.Bound(p => p.affaire.mnemonique) .ClientTemplate("#= affaire.mnemonique #" + "<input type='hidden' name='Activites[#= index(data)#].affaire.mnemonique' value='#= affaire.mnemonique #' />") .Width(150); columns.Bound(p => p.heures) //.ClientTemplate(Html.Kendo().NumericTextBox<Decimal>() // .Name("Activites[#=index(data)#].heures") // .HtmlAttributes(new { type = "hidden", value = "#=heures#" }) // .Format("{n2}") // .Decimals(2) // .Min(0) // .ToClientTemplate().ToHtmlString() // ) .ClientTemplate("#= heures #" + "<input type='hidden' name='Activites[#= index(data)#].heures' value='#= heures #' data-format='n2' data-decimals='2' data-step='0.01' data-role='numerictextbox' />") //.ClientGroupFooterTemplate("Heures : #=sum#") .Width(100); columns.Bound(p => p.deplacement) .ClientTemplate("#= deplacement #" + "<input type='hidden' name='Activites[#= index(data)#].deplacement' value='#= deplacement #' />") .Width(100); columns.Bound(p => p.zone) .ClientTemplate("#= zone.libelle #" + "<input type='hidden' name='Activites[#= index(data)#].zone.code' value='#= zone.code #' />") .Width(150); columns.Command(command => command.Destroy()).Width(30); }) .Events(events => events.DataBound("onDataBoundSaisieHeures")) .ToolBar(toolbar => { toolbar.Create(); }) .Resizable(resize => resize.Columns(true)) .Editable(editable => editable.Mode(GridEditMode.InCell)) .Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple)) .Sortable() .Scrollable() .Navigatable() // Permet de changer de cellule en édition par exemple ! ;-) .Groupable() .DataSource(dataSource => dataSource .Ajax() .Aggregates(aggregates => { aggregates.Add(p => p.heures).Sum(); }) .Batch(true) .ServerOperation(false) .Model(model => { model.Id(p => p.rowId); // On indique des valeurs par défaut pour le bind des objets sinon erreur. model.Field(p => p.client).DefaultValue( new Integraal.Models.ActiviteClientViewModel { code = "", raisonSociale = "" } ); model.Field(p => p.affaire).DefaultValue( new Integraal.Models.Affaire { code = "", mnemonique = "" } ); model.Field(p => p.zone).DefaultValue( new Integraal.Models.Zone { code = "", libelle = "" } ); }) .Read(read => read.Action("editing_read", "activites").Data("additionalDataRead")) ))my problems is on the columns "heures", i need to send a Decimal value to the controller.
But in my controller the activite.heures is always at 0 -_-'
all others values are set correctly except heures
[HttpPost]
public PartialViewResult Edition(Activite activite)
{
List<Activite> edited = new List<Activite>();
List<Activite> deleted = new List<Activite>();
...
someone have any idea ?
@(Html.Kendo().Grid<Person>() .Name("grid") .Columns(columns => { columns.Bound(x => x.FirstName).Title("First Name"); columns.Bound(x => x.LastName).Title("Last Name"); columns.Bound(x => x.EmailAddress).Title("Email Address"); columns.Bound(x => x.PhoneNumber).Title("Phone Number"); }) .DataSource(dataSource => dataSource .Ajax() .Read(read => read.Action("LoadGrid", "Dashboard") .Data("my.view.parms") // the name of the JavaScript function which will return the additional data ) ) )
var show = function () { reloadGrid("#grid"); showWindow("#window", "Lead Report"); };
var reloadGrid = function(gridElement) { var grid = $(gridElement).data("kendoGrid"); grid.dataSource.read(); };
var showWindow = function(element, title, width, actions) { var window = $(element); window.show(); if (!window.data("kendoWindow")) { window.kendoWindow({ width: width || "1400px", title: title, actions: actions || ["Close"], modal: true }); } $(element).data("kendoWindow").center().open(); };
"ID"and "Gamme" of table delegue in the same row as rows of RapportView .i hope that my problem is clear.Thanks for yr help.[{"Cycle":"2008",
"DateDebut":"\/Date(1202684400000+0100)\/",
"DateFin":"\/Date(1203202800000+0100)\/",
"Delegue":{"Gamme":"BU 1A","ID":13,"Matricule":"033","Nom":"S","Prenom":"Sa","Role":null}
},
{
"Cycle":"2008",
"DateDebut":"\/Date(1203289200000+0100)\/",
"DateFin":"\/Date(1203807600000+0100)\/","Delegue":{"Gamme":"BU 1A","ID":13,"Matricule":"033","Nom":"S","Prenom":"Sa","Role":null}
}]
|
|
I have implemented inline editing with Knedo UI MVC grid with Ajax binding, Server side validation handled in controller and sending the error back using -
ModelState.AddModelError("Error: ", ex.Message);
@(Html.Kendo().Grid<AnalyticsServiceWeb.ViewModel.SomeViewModel>() .Name("Grid") .Columns(columns => { columns.Bound(p => p.Name); columns.Bound(p => p.Path); columns.Bound(p => p.Space); columns.Command(command => { command.Edit(); command.Destroy(); }); }) .ToolBar(toolbar => toolbar.Create()) .Editable(editable => editable.Mode(GridEditMode.InLine)) )
function error_handler(e) {
if (e.errors) {
var message = "Errors:\n";
$.each(e.errors, function (key, value) {
if ('errors' in value) {
$.each(value.errors, function () {
message += this + "\n";
});
}
});
alert(message);
}
}
The server side error message is getting displayed when there is a server side exception, but it still completes the action in UI, i mean it adds the new record to the grid and update as well even though there is server side exception.
Is there any way to retain the state of UI before the action start?, it supposed to work in that way, not sure if i am missing anything?
Thanks in advance
Using version 2012.3.1114.
This work using Visual Studio Development Server but does not show the drop down using IIS Express or IIS 7 on Windows Server 2008 R2
Code in view:
@(Html.Kendo().ComboBoxFor(m => m.ForPost) .Filter(FilterType.StartsWith) .DataTextField("label") .DataValueField("value") .MinLength(1) .DataSource(source => { source.ServerFiltering(); source.Read(read => { read.Action("AjaxPost", "Home"); //Set the Action and Controller name read.Type(HttpVerbs.Post); }); }))
[HttpPost]public ActionResult AjaxPost(string text) { if (string.IsNullOrWhiteSpace(text)) return Json(null); var x = Data.Where(d => d.StartsWith(text, StringComparison.InvariantCultureIgnoreCase)) .Select(d => new { label = d, value = d }).ToList(); return Json(x);}IE 9 in Javascript debug it shows this error "Microsoft JScript runtime error: Unable to get value of the property 'Errors': object is null or undefined" and pints the this dynamic code.
function anonymous(d) {return d.Errors}Using get works fine but our security people insist we use post for ajax.
Thanks,
Tom Wilkinson
