I am using a kendo grid with multiple columns. But i need to display few columns with red asterick to indicate required filed. Can someone help me on this.
<div id="failureTypeInfoGrid" style="width:100%;overflow-x:auto;">
#(Html.Kendo().Grid(Model.lstSerialData)
.Name("serialGrid")
.Events(e => e.Edit("onEdit"))
.Columns(columns =>
{
columns.Bound(c => c.UnitId).Hidden(true).ClientTemplate("#= UnitId #" +
"<input type='hidden' name='SerialData[#= index(data)#].UnitId' value='#= UnitId #' />"
);
columns.Bound(c => c.SerialNumber).Title("Unit No/Serial No*").ClientTemplate("#= SerialNumber #" +
"<input type='hidden' name='SerialData[#= index(data)#].SerialNumber' value='#= SerialNumber #' />"
);
columns.ForeignKey(p => p.Failure_Subjected_To, (System.Collections.IEnumerable)ViewData["FailureSubjectedTo"], dataFieldValue: "ValueId", dataFieldText: "ValueName").Width(140).ClientTemplate("#= getValue(Failure_Subjected_To) #" +
"<input type='hidden' name='SerialData[#= index(data)#].Failure_Subjected_To' value='#= Failure_Subjected_To #' />"
).Title("Fail Subjected To");
columns.Bound(c => c.Hours_Before_Failure).ClientTemplate("#= Hours_Before_Failure #" +
"<input type='hidden' name='SerialData[#= index(data)#].Hours_Before_Failure' value='#= Hours_Before_Failure #' />"
).Title("Hours Before Failure (Hours)");
columns.Bound(c => c.Failure_Temperature).ClientTemplate("#= Failure_Temperature #" +
"<input type='hidden' name='SerialData[#= index(data)#].Failure_Temperature' value='#= Failure_Temperature #' />"
).Title("Failure Temperature (Celsius)");
columns.Bound(c => c.Component_LTC_Code).ClientTemplate("#= Component_LTC_Code #" +
"<input type='hidden' name='SerialData[#= index(data)#].Component_LTC_Code' value='#= Component_LTC_Code #' />"
).Title("Manufacturing Date/LTC Code");
columns.Bound(c => c.Board_Ref_Designator).ClientTemplate("#= Board_Ref_Designator #" +
"<input type='hidden' name='SerialData[#= index(data)#].Board_Ref_Designator' value='#= Board_Ref_Designator #' />"
).Title("Board Ref Designator");
columns.Bound(c => c.FailureMode).Hidden(true).HtmlAttributes(new { style = "height: 20px;" }).ClientTemplate("#= FailureMode #" +
"<input type='hidden' name='SerialData[#= index(data)#].FailureMode' value='#= FailureMode #' />"
);
columns.Bound(c => c.FailureMechanism).Hidden(true).ClientTemplate("#= FailureMechanism #" +
"<input type='hidden' name='SerialData[#= index(data)#].FailureMechanism' value='#= FailureMechanism #' />"
);
columns.Bound(c => c.FailureModeName).Title("Failure Mode");
columns.Bound(c => c.FailureMechanismName).Title("Failure Mechanism");
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.HtmlAttributes(new { style = "height: 200px;overflow-x:auto" })
//.Scrollable()
.Resizable(resize => resize.Columns(true))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.ServerOperation(false)
.Model(model => { model.Id(p => p.Id); model.Field(p => p.FailureModeName).Editable(false); model.Field(p => p.FailureMechanismName).Editable(false); })
)
)
</div>
I want to display red asterik after unit serial number.
Please try with the below code snippet. We can achieve this thing by using header template.
columns.Bound(c => c.SerialNumber).HeaderTemplate("Unit No/Serial No" + "<span style='color:red;'>*</span>");
Let me know if any concern.
Related
I am trying to add functionality (adding filters to Kendo Grid), to an existing kendo MVC grid. Please see below code of the Grid. I added filters for each column, but not able to get the filtered results. Please let me know any changes to code.
Thanks in advance.
'''
#(Html.Kendo().Grid(Model)
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.RankNumber).Title("Rank").Width(80).Filterable(ftb =>
ftb.Multi(true).Search(true)); ;
columns.Bound(p => p.IDSRequestID).Title("ID").ClientTemplate("#if(IDSRequestID>0){#" +
"<a target='_blank' href =
'" + Url.Action("Edit", "ServiceCatalog") + "?id=#=IDSRequestID#'>#= IDSRequestID#</a>" +
"<input type='hidden'
name='RankStatus' value='#= RankStatus#'/>" +
"#}else {# <span
class='hiddenRow'></span>#}#").Width(80).Filterable(ftb =>
ftb.Multi(true).Search(true)); ;
columns.Bound(p => p.UnitName).Title("Unit Name").Hidden();
columns.Bound(p => p.TeamName).Title("Team Name").Width(80).Filterable(ftb =>
ftb.Multi(true).Search(true)); ;
columns.Bound(p => p.EffortLeft).Title("Effort Left").Width(80).Filterable(ftb =>
ftb.Multi(true).Search(true)); ;
columns.Bound(p => p.CustName).Title("Customer Name").Width(80).Filterable(ftb =>
ftb.Multi(true).Search(true));
columns.Bound(p => p.Status).Title("Status").Width(80).Filterable(ftb =>
ftb.Multi(true).Search(true));
columns.Bound(p => p.SegmentServiced).Title("Segment Serviced").Hidden();
columns.Bound(p => p.ProductClass).Title("Product Class").Hidden();
columns.Bound(p => p.Projects).Title("Projects").Hidden();
})
.Sortable()
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.Group(groups => groups.Add(p => p.RankStatus))
).Events(e => e.DataBound("GroupCollapse_user")))
'''
Hi since you are anyways adding filtering for all coulmns (non hidden columns)..Can you try like this and see if it works
#(Html.Kendo().Grid(Model)
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.RankNumber).Title("Rank").Width(80);
columns.Bound(p => p.IDSRequestID).Title("ID").ClientTemplate("#if(IDSRequestID>0){#" +
"<a target='_blank' href =
'" + Url.Action("Edit", "ServiceCatalog") + "?id=#=IDSRequestID#'>#= IDSRequestID#</a>" +
"<input type='hidden'
name='RankStatus' value='#= RankStatus#'/>" +
"#}else {# <span
class='hiddenRow'></span>#}#").Width(80);
columns.Bound(p => p.UnitName).Title("Unit Name").Hidden();
columns.Bound(p => p.TeamName).Title("Team Name").Width(80);
columns.Bound(p => p.EffortLeft).Title("Effort Left").Width(80);
columns.Bound(p => p.CustName).Title("Customer Name").Width(80);
columns.Bound(p => p.Status).Title("Status").Width(80);
columns.Bound(p => p.SegmentServiced).Title("Segment Serviced").Hidden();
columns.Bound(p => p.ProductClass).Title("Product Class").Hidden();
columns.Bound(p => p.Projects).Title("Projects").Hidden();
})
.Sortable()
.Filterable(ftb => ftb.Multi(true))
.DataSource(dataSource => dataSource
.Ajax()
.Group(groups => groups.Add(p => p.RankStatus))
).Events(e => e.DataBound("GroupCollapse_user")))
I have some problems to set the height to a kendo grid's. It's simple what i'm trying to do. I want the grid fills all the div where it's placed.
This is my code
<div class="col-lg-6" style="height:316px;">
#(Html.Kendo().Grid<empresas_personas>(Model.empresas_personas)
.Name("empresas_personas")
.ToolBar(t => {
t.Create();
})
.Filterable(f=>f
.Enabled(true)
.Mode(GridFilterMode.Menu)
// .Extra(false)
//.Operators(ops=>ops.ForString(str=>str.Clear().Contains("Contains")))
)
.Excel(e=>e.FileName("Personas").AllPages(true))
.Sortable(s=>s.Enabled(true).SortMode(GridSortMode.MultipleColumn).AllowUnsort(true))
.Selectable(s => s.Mode(GridSelectionMode.Multiple).Type(GridSelectionType.Row))
.Scrollable()
.HtmlAttributes(new { #style = "height:316px;"})
.Columns(columns =>
{
columns.Bound(c => c.Id).Hidden().ClientTemplate("#= Id #" +
"<input type='hidden' name='empresas_personas[#= indexPersonasEmpresa(data)#].Id' value='#= Id #' />");
columns.Bound(c => c.NombreDomicilio)
.ClientTemplate("#= NombreDomicilio #" +
"<input required='true' type='hidden' name='empresas_personas[#= indexPersonasEmpresa(data)#].NombreDomicilio' value= '#= NombreDomicilio ? NombreDomicilio : '' #' />")
.Sortable(true)
.Filterable(f=>f.Operators(ops => ops.ForString(str => str.Clear().Contains("Contiene"))))
.Title("Nombre");
columns.Bound(c => c.Cargo)
.ClientTemplate("#= Cargo #" +
"<input required='true' type='hidden' name='empresas_personas[#= indexPersonasEmpresa(data)#].Cargo' value= '#= Cargo ? Cargo : '' #' />")
.Sortable(true)
.Filterable(f => f.Operators(ops => ops.ForString(str => str.Clear().Contains("Contiene"))))
.Title("Cargo");
columns.Command(command =>
{
command.Edit().Text(" ").HtmlAttributes(new { #style = "padding:0px; min-width:25px; padding-left: 0.4em;" });
command.Destroy().Text(" ").HtmlAttributes(new { #style = "padding:0px; min-width:25px; padding-left: 0.3em;" });
}).Width(80);
//columns.Bound(c => c.Cargo)
// .ClientTemplate("<input type='hidden' name='empresas_personas[#= indexPersonasEmpresa(data)#].Cargo' value='#= Cargo ? Cargo : '' #' />");
#*Hidden*#
columns.Bound(c => c.Calle).Hidden().ClientTemplate("<input type='hidden' name='empresas_personas[#= indexPersonasEmpresa(data)#].Calle' value='#= Calle ? Calle : '' #' />");
columns.Bound(c => c.Codigo_postal).Hidden().ClientTemplate("<input type='hidden' name='empresas_personas[#= indexPersonasEmpresa(data)#].Codigo_postal' value='#= Codigo_postal ? Codigo_postal : '' #' />");
columns.Bound(c => c.IdPoblacionAvalon).Hidden().ClientTemplate("<input type='hidden' name='empresas_personas[#= indexPersonasEmpresa(data)#].IdPoblacionAvalon' value='#= IdPoblacionAvalon ? IdPoblacionAvalon : '' #' />");
columns.Bound(c => c.Email).Hidden().ClientTemplate("<input type='hidden' name='empresas_personas[#= indexPersonasEmpresa(data)#].Email' value='#= Email ? Email : '' #' />");
columns.Bound(c => c.Telefono_movil).Hidden().ClientTemplate("<input type='hidden' name='empresas_personas[#= indexPersonasEmpresa(data)#].Telefono_movil' value='#= Telefono_movil ? Telefono_movil : '' #' />");
columns.Bound(c => c.Telefono_fijo).Hidden().ClientTemplate("<input type='hidden' name='empresas_personas[#= indexPersonasEmpresa(data)#].Telefono_fijo' value='#= Telefono_fijo ? Telefono_fijo : '' #' />");
columns.Bound(c => c.Telefono_fax).Hidden().ClientTemplate("<input type='hidden' name='empresas_personas[#= indexPersonasEmpresa(data)#].Telefono_fax' value='#= Telefono_fax ? Telefono_fax : '' #' />");
columns.Bound(c => c.Observaciones).Hidden().ClientTemplate("<input type='hidden' name='empresas_personas[#= indexPersonasEmpresa(data)#].Observaciones' value='#= Observaciones ? Observaciones : '' #' />");
columns.Bound(c => c.IdEmpresa).Hidden().ClientTemplate("#= IdEmpresa #" +
"<input type='hidden' name='empresas_personas[#= indexPersonasEmpresa(data)#].IdEmpresa' value='#= IdEmpresa #' />");
// columns.Bound(c => c.IdCargo).Hidden().ClientTemplate("<input name='empresas_personas[#= indexPersonasEmpresa(data)#].IdCargo' value='#= IdCargo ? IdCargo : '' #' />");
//columns.Bound(c => c.CargoStr).Hidden().ClientTemplate("#= cargos==null ? cargos.Nombre : '' #" +
// "<input type='hidden' name='empresas_personas[#= indexPersonasEmpresa(data)#].cargos.Nombre' value='#= cargos ? cargos.Nombre : '' #' />");
})
.Events(e => e.Edit("onEdit").Change("onChangePersona"))
.Editable(editable => editable.Mode(GridEditMode.PopUp).CreateAt(GridInsertRowPosition.Top).TemplateName("popUpPersonas")
// .Window(w=>w.Events(ev=>ev.Activate("onOpenPersonasContacto")))
)
.DataSource(dataSource => dataSource.Ajax()
.Create(c => c.Action("FakeGridCreate", "Empresas"))
.Destroy(d => d.Action("FakeGridDestroy", "Empresas"))
.Update(d => d.Action("FakeGridUpdate", "Empresas"))
.Model(model =>
{
model.Id(p => p.Id);
model.Field(p => p.IdEmpresa).DefaultValue(Model.Id).Editable(false);
model.Field(p => p.Calle).DefaultValue(Model.Domicilio_social).Editable(true);
model.Field(p => p.Codigo_postal).DefaultValue(Model.Codigo_postal).Editable(true);
//model.Field(p => p.IdPoblacionAvalon).DefaultValue(Model.IdPoblacion).Editable(true);
model.Field(p => p.Telefono_fijo).DefaultValue(Model.Telefojo_fijo_empresa).Editable(true);
model.Field(p => p.Telefono_movil).DefaultValue(Model.Telefono_movil_empresa).Editable(true);
model.Field(p => p.Telefono_fax).DefaultValue(Model.Telefono_fax_empresa).Editable(true);
model.Field(p => p.Email).DefaultValue(Model.Email).Editable(true);
})
.ServerOperation(false)
)
)
</div>
However it renders like this:
As you can see a strange white band appears.
I have tried the solution provided by telerik: http://jsbin.com/yumexugo/1/edit?html,css,js,output changing my code like this:
//same thing here
.HtmlAttributes(new { #style = "height:100%;"})
//same here
<script type="text/javascript">
$(document).ready(function () {
//resizeWrapper();
resizeGrid();
});
function resizeGrid() {
debugger;
var gridElement = $("#empresas_personas"),
dataArea = gridElement.find(".k-grid-content"),
gridHeight = gridElement.innerHeight(),
otherElements = gridElement.children().not(".k-grid-content"),
otherElementsHeight = 0;
otherElements.each(function () {
otherElementsHeight += $(this).outerHeight();
});
dataArea.height(gridHeight - otherElementsHeight);
}
</script>
But in this case the height of the parent's div, it's completely ignored:
If i set the height to 316px, but i execute the javascript on document ready, it still appear a white band, and the scrollbar is too big:
It's been almost 3 years since the function your are using for the setting the height has been written. Since then, some DOM elements has been added to the grid and I had to review some part of the logic make sure to consider those new elements in the calculation and their state (because some of them may be hidden):
kendo.ui.Grid.prototype.redraw = function () {
var jqElement = this.element;
var gridHeight = jqElement.innerHeight();
var dataArea = jqElement.find(".k-grid-content");
var otherElements = jqElement.children().not(".k-grid-content");
var otherElementsHeight = 0;
otherElements.each(function (index, otherElement) {
otherElementsHeight += $(otherElement).is(':visible') ? $(otherElement).outerHeight() : 0;
});
dataArea.height(gridHeight - otherElementsHeight);
};
Actually, the code above is an extension to the kendoGrid object and it assumes you have already set the height of the root element. Once the height is set, you can call the redraw function like this: $("#YourGrid").data("kendoGrid").redraw
I want to Auto calculate Kendo Grid Column on client side. My code is
#(Html.Kendo().Grid(Model)
.Name("VATGrid")
.Columns(columns =>
{
columns.Bound(p => p.BaseAmount);
columns.Bound(x => x.Unit);
columns.Bound(p => p.VATPercentage);
columns.Bound(p => p.VATAmount)
.HeaderHtmlAttributes(new { title = "VAT Amount" })
.HtmlAttributes(new { style = "text-align:right" })
.Title("VAT Amount")
.ClientTemplate(
"#= VATAmount=kendo.toString(BaseAmount*Unit*VATPercentage, 'n2')#" +
"<input type='hidden' class='VATAmount' value='#=kendo.toString(BaseAmount*Unit*VATPercentage, 'n4')#' />");
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.ServerOperation(false)
.Model(model =>
{
model.Id(p => p.DocumentVATID);
model.Field(x => x.CompanyVATType).Editable(false);
model.Field(x => x.VATPercentage).Editable(false);
model.Field(x => x.VATType).Editable(false);
model.Field(x => x.BaseAmount).DefaultValue(0);
model.Field(x => x.Unit).DefaultValue(0);
})
)
Where I am able to get Auto calculated value but after clicking on the Grid Cell.
I want to show calculated value on change itself
Something like this?
#(Html.Kendo().Grid(Model)
.Name("VATGrid")
.Columns(columns =>
{
columns.Bound(p => p.BaseAmount);
columns.Bound(x => x.Unit);
columns.Bound(p => p.VATPercentage);
columns.Bound(p => p.VATAmount)
.HeaderHtmlAttributes(new { title = "VAT Amount" })
.HtmlAttributes(new { style = "text-align:right" })
.Title("VAT Amount")
//.ClientTemplate(
//"#= VATAmount=kendo.toString(BaseAmount*Unit*VATPercentage, 'n2')#" +
//"<input type='hidden' class='VATAmount' value='#=kendo.toString(BaseAmount*Unit*VATPercentage, 'n4')#' />");
//})
.ClientTemplate(
"<span id="vatId">#= VATAmount=kendo.toString(BaseAmount*Unit*VATPercentage, 'n2')#</span>" +
"<input type='hidden' class='VATAmount' value='#=kendo.toString(BaseAmount*Unit*VATPercentage, 'n4')#' />");
})
//put span tag around the clienttemplate above
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Events(e => e.Change("onProductChange")) //add this event listener
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.ServerOperation(false)
.Model(model =>
{
model.Id(p => p.DocumentVATID);
model.Field(x => x.CompanyVATType).Editable(false);
model.Field(x => x.VATPercentage).Editable(false);
model.Field(x => x.VATType).Editable(false);
model.Field(x => x.BaseAmount).DefaultValue(0);
model.Field(x => x.Unit).DefaultValue(0);
})
)
<script type="text/javascript">
function onChange(e) {
var selected = $.map(this.select(), function (item) {
return $(item).text();
});
console.log("Selected: " + selected.length + " item(s), [" + selected.join(", ") + "]");
//TODO: calculate your data and use calc variables below
var calc1 = 0;
var calc2 = 0;
$("#vatId").text(calc);
$(".VATAmount").val(calc2); //or something like that, but you get the grip
}
</script>
Perhaps I´m misunderstanding your problem but it sounds to me as if you want to calculate the data in your footertemplate each time a cell is selected.
Current scenario, demand deletion of the Kendo Gird column at runtime, I was wondering if there is any way to place checkbox or radio Button for Column header?
Like this,
#(Html.Kendo().Grid<TwoModelInSinglePageModel.SampleModel>()
.Name("grid12")
.Columns(columns =>
{
columns.Bound(p => p.studentclass).HeaderTemplate("<input id='selectall' class='chkbxq' type='checkbox' />").ClientTemplate("<input id='checkbox_#=inx#' class='chkbxq' type='checkbox' />");
columns.Bound(p => p.SampleDescription).HeaderTemplate("<input id='chkSampleDescription' class='chkbxq' type='checkbox' />");
columns.Bound(p => p.SampleCode).HeaderTemplate("<input id='chkSampleCode' class='chkbxq' type='checkbox' />");
columns.Bound(p => p.SampleItems).HeaderTemplate("<input id='chkSampleItems' class='chkbxq' type='checkbox' />");
})
.Pageable()
.Navigatable()
//.Filterable()
.Sortable()
.Groupable()
.Events(events => events.DataBound("_GridItemDataBound"))
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(p => p.inx))
.Read(read => read.Action("Read", "Test"))
)
)
I have 3 Kendo grids and a Save button in a view. When I click on Save button, I get the updated ViewModel in my controller’s action method which in turns add/update records in database. But the save action method is called 3 times because there are 3 kendo grids on the view. I removed 2 grids from the view and it post backs only time since the view has only one grid (weird).
How to stop multiple postbacks when the Save button is clicked?
Index.cshtml
#using (Html.BeginForm("Save", "UDFController", FormMethod.Post))
{
<input class="button" type="submit" name="save" value="Save"/>
#(Html.Kendo().Grid(Model.List1)
.Name("List1")
.HtmlAttributes(new { style = "width:auto;height:100%" })
.ToolBar(toolbar => toolbar.Create().Text("Add New Record"))
.Editable(editable => editable.Mode(GridEditMode.InCell).CreateAt(GridInsertRowPosition.Top))
.Columns(columns =>
{
columns.Bound(p => p.Title)
.ClientTemplate("#= Title #" +
"<input type='hidden' name='DateFields[#= index(data)#].Title' value='#= Title #' />")
.Title("Title").HtmlAttributes(new { style = "width:30%" });
columns.Bound(p => p.MaxPrecision).Title("Decimal Places")
.ClientTemplate("#= MaxPrecision #" +
"<input type='hidden' name='DateFields[#= index(data)#].MaxPrecision' value='#= MaxPrecision #' />");
columns.Bound(p => p.IsObsolete).Title("Obsolete")
.ClientTemplate("#= IsObsolete #" +
"<input type='hidden' name='DateFields[#= index(data)#].IsObsolete' value='#= IsObsolete #' />");
})
.DataSource(datasource => datasource
.Ajax()
.Model(model =>
{
{
model.Id(p => p.Title);
model.Field(p => p.Title).Editable(true);
model.Field(p => p.MaxPrecision).Editable(true);
model.Field(p => p.IsObsolete).Editable(true);
}
}
)
)
)
#(Html.Kendo().Grid(Model.List2)
.Name("List2")
.HtmlAttributes(new { style = "width:auto;height:100%" })
.ToolBar(toolbar => toolbar.Create().Text("Add New Record"))
.Editable(editable => editable.Mode(GridEditMode.InCell).CreateAt(GridInsertRowPosition.Top))
.Columns(columns =>
{
columns.Bound(p => p.Title)
.ClientTemplate("#= Title #" +
"<input type='hidden' name='DateFields[#= index(data)#].Title' value='#= Title #' />")
.Title("Title").HtmlAttributes(new { style = "width:30%" });
columns.Bound(p => p.MaxPrecision).Title("Decimal Places")
.ClientTemplate("#= MaxPrecision #" +
"<input type='hidden' name='DateFields[#= index(data)#].MaxPrecision' value='#= MaxPrecision #' />");
columns.Bound(p => p.IsObsolete).Title("Obsolete")
.ClientTemplate("#= IsObsolete #" +
"<input type='hidden' name='DateFields[#= index(data)#].IsObsolete' value='#= IsObsolete #' />");
})
.DataSource(datasource => datasource
.Ajax()
.Model(model =>
{
{
model.Id(p => p.Title);
model.Field(p => p.Title).Editable(true);
model.Field(p => p.MaxPrecision).Editable(true);
model.Field(p => p.IsObsolete).Editable(true);
}
}
)
)
)
#(Html.Kendo().Grid(Model.List3)
.Name("List3")
.HtmlAttributes(new { style = "width:auto;height:100%" })
.ToolBar(toolbar => toolbar.Create().Text("Add New Record"))
.Editable(editable => editable.Mode(GridEditMode.InCell).CreateAt(GridInsertRowPosition.Top))
.Columns(columns =>
{
columns.Bound(p => p.Title)
.ClientTemplate("#= Title #" +
"<input type='hidden' name='DateFields[#= index(data)#].Title' value='#= Title #' />")
.Title("Title").HtmlAttributes(new { style = "width:30%" });
columns.Bound(p => p.MaxPrecision).Title("Decimal Places")
.ClientTemplate("#= MaxPrecision #" +
"<input type='hidden' name='DateFields[#= index(data)#].MaxPrecision' value='#= MaxPrecision #' />");
columns.Bound(p => p.IsObsolete).Title("Obsolete")
.ClientTemplate("#= IsObsolete #" +
"<input type='hidden' name='DateFields[#= index(data)#].IsObsolete' value='#= IsObsolete #' />");
})
.DataSource(datasource => datasource
.Ajax()
.Model(model =>
{
{
model.Id(p => p.Title);
model.Field(p => p.Title).Editable(true);
model.Field(p => p.MaxPrecision).Editable(true);
model.Field(p => p.IsObsolete).Editable(true);
}
}
)
)
)
}
Controller Code
[HttpPost]
public ActionResult Save(ListViewModel viewModel)
{
//This is getting called 3 times. But this is supposed to be called 1 time
if (ModelState.IsValid)
{
if (viewModel != null)
{
try
{
viewModel.Save(viewModel);
return View("Index", viewModel);
}
catch (Exception e)
{
return View("Index", viewModel);
}
}
}
I think that is to be expected since you have 3 ajax enabled grids. Since they are setup as ajax grids they should operate independent of one another.
I think if null is passed to the Datasource of the kendo Grid in the html helper, the Grid will be built in remote data mode rather than local data mode and since the read Url is not set the current browser Url will be used for the read operation.
The fix is very easy just make sure to initialize the list in the Model before using it as a Datasource.
Like this:
Html.Kendo().Grid(Model.List1)
Model.List1 needs to be initialized.