Enum class
public class Voltage { public int Id{ get; set; } public string RefNo { get; set; } public VoltageLevel VoltageLevel { get; set; } } public enum VoltageLevel { LV = 1, MV = 2, HV = 3 }
Controller
public ActionResult Voltage_Read([DataSourceRequest]DataSourceRequest request) { IQueryable<Voltage> voltage= db.Voltage; DataSourceResult result = voltage.ToDataSourceResult(request, voltage=> new { Id = voltage.Id, RefNo = voltage.RefNo, VoltageLevel = voltage.VoltageLevel, }); return Json(result); }
View
@(Html.Kendo().Grid<entities.voltage>().Name("grid").Columns(columns =>{columns.Bound(c => c.RefNo);columns.Bound(c => c.VoltageLevel); //here the voltagelevel didnt show. })
Kendo Grid creates some dynamic id like 90gaedac-c800-4582-b530-4f7145383554 and they sometimes start with a number, which is against the standard.
https://css-tricks.com/ids-cannot-start-with-a-number/
Is there a way to fix this behaviour?

Hello, I'm using a cascading combobox in an editor template. The Id is set dynamically to avoid conflict with multiple instances of the editor on the same page. So for example I might setup the editor like this:
@Html.EditorFor(o => o.MatterNum, "MatterComboBox", new { ControlId = "upload_Matter" })
It sets the Id dynamically and that works great ( see below ). The problem I'm having is with cascading, because the parent combobox is also dynamic, so I don't know what the ID will be in my additional data method. I need to be able to somehow pass the ID of the parent combobox when setting up the child. Here is how my child combo is defined (the parent is very similar):
@(Html.Kendo().ComboBoxFor(o => o)
.DataTextField("MatterNumName")
.DataValueField("MatterNum")
.Placeholder("Select Matter")
.HtmlAttributes(new { id = @ViewData["ControlId"], style = "width: 100%" })
.Filter("contains")
.AutoBind(true)
.MinLength(1)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetFilteredMatters", "ClientMatter")
.Data("onAdditionalMatterData");
})
.ServerFiltering(true);
})
)
I've come at this from a few angles but coming up short each time.
1. I can set the child/parent IDs to be similar so I could just infer the parent Id from the child. However I haven't found a way to get the child combobox Id inside the onAdditionalMatterData js function, it seems to only contain the filter data (which I also need). If there was a way to get the sending control information out of that fitler object I think it would solve my issue.
2. I thought maybe I could pass the Id along from the template view to the onAdditionalMatterData function, something like this:
.Data("eBillReady.ClientMatterLookups.onAdditionalMatterData('parentId')");
but I'm not sure how to do that without losing the filter data which is then no longer passed, also I would obviously need the name to populate dynamically perhaps from the viewdata.
3. I think if I dynamically set "CascadeFrom", then that may cause the Id to be part of that filters object passed to onAdditionalMatterData but I didn't get anywhere with that. Maybe setting that manually in the page load would work?

Hi,
My notification is
@foreach (SLEmailMessage x in Model.Notifications)
{
@:var subject = '@x.Subject';
@:var body = '@x.Body';
@: notification.show({ title: subject, message: body }, "upload-success");
}
});
In my controller
Where @x.Body = "Building = 101" + Environment.NewLine +
"Manager Name: " + "Ali Baba";
The Environment.NewLine is causing an error. How to add a "end on line" in the notification?
I tried to replace the "end on line" by the <br> tag within a paragraph and it dit not work
A quick answer will be greatly appreciated
I have a DDL (below that is not binding to my controller (also below). The contact controller/View are part of an area.
Please assist.
Thanks in advance
Controller
public ActionResult GetCountries([DataSourceRequest] DataSourceRequest dsRequest)
{
List<DropDownListModel> result = new List<DropDownListModel>();
foreach (DataRow dr in CommonWf.getLocationByTypeId(4).Tables[0].Rows)
{
if (!string.IsNullOrEmpty(dr["Name"].ToString()))
{
DropDownListModel returnModel = new DropDownListModel();
returnModel.Name = dr["Name"].ToString();
returnModel.Value = dr["LocationId"].ToString();
result.Add(returnModel);
}
}
DataSourceResult crapData = result.ToDataSourceResult(dsRequest);
return Json(crapData, JsonRequestBehavior.AllowGet);
}
Dropdown List
@(Html.Kendo().DropDownList()
.Name("CountryId")
.DataTextField("Name")
.DataValueField("Value")
.Events(e =>
{
e.Select("onChangeCountry"); //.DataBound("onCountryBound");
})
.OptionLabel("Select Country...")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetCountries", "Contact");
})
.ServerFiltering(true);
})
)

Trying to apply (default filter) active.
where plu.pluActive is a boolean
I have tried:
.Filter(filters => { filters.Add(plu => plu.pluActive == true); }).Filter(filters => { filters.Add(plu => plu.pluActive).Equals(true); }).Filter(filters => { filters.Add(plu => plu.pluActive).Equals("true"); })They all filter out all the rows.
If I comment out:
//.Filter(filters => { filters.Add(plu => plu.pluActive == true); })
I get all the rows.
???
Hi, i've a treelist with custom command,
and i'm trying to change the button template with the databound event like the Grid
the visual result it's ok, but the event click doesn't fire, probably because i remove the k-button class.
but if leave the class the button doesn't template.
columns.Add().Command(command => { command.Custom().ClassName("k-grid-EditCustom").Text(" ").Name("EditCustom").Click("editGroup"); command.Custom().ClassName("k-grid-DeleteCustom").Text(" ").Name("DeleteCustom").Click("deleteGroup"); }).Width(150);
function treeGridGroup_DataBound(e) { e.sender.tbody.find(".k-grid-EditCustom").removeClass("k-button") e.sender.tbody.find(".k-grid-EditCustom").addClass("btn btn-warning btn-outline fa fa-pencil"); e.sender.tbody.find(".k-grid-DeleteCustom").removeClass("k-button") e.sender.tbody.find(".k-grid-DeleteCustom").addClass("btn btn-danger btn-outline fa fa-trash-o m-l-5"); }I'm working on a Kendo UI Grid using ASP.NET MVC. We're having an issue with the grid sticking on a specific page. If the user makes their selections and the grid brings back ten pages, it displays fine. However, if the user makes navigates to page 10 and then makes another selection that only brings back 5 pages, the grid is blank, but the correct page numbers display. If the user clicks on one of the page numbers, the data displays correctly.
Here's my grid:
@(Html.Kendo().Grid<SMT.Models.SpecimenDetail>() .Name("SpecimenDetailGrid") .Columns(columns => { columns.Bound(e => e.uniqueID).Hidden(); columns.Bound(e => e.SampleID).Width(180).Title("Specimen ID").ClientTemplate("#= fileLinks(data) #"); columns.Bound(e => e.contactId).Hidden(); columns.Bound(e => e.contact_business_email).Width(120).Title("Owner Email"); columns.Bound(e => e.contact_business_phone).Width(120).Title("Owner Phone"); }) .ToolBar(tools => { tools.Excel(); tools.Custom().Text("Back to Specimen Summary").HtmlAttributes(new { id = "goBack", style = "margin-left: 880px;" }); }) .Excel(excel => excel .AllPages(true) .FileName("SpecimenDetailGridData.xlsx") .Filterable(true) .ProxyURL(Url.Action("Excel_Export_Save", "Home")) ) .Resizable(x => x.Columns(true)) .Reorderable(x => x.Columns(true)) .Scrollable() .Sortable() .HtmlAttributes(new { style = "height:500px;" }) .Pageable() .Filterable() .AutoBind(false) .Editable(e => e.Mode(GridEditMode.InLine)) .DataSource(datasource => datasource .Ajax() .Model(model => { model.Id(p => p.uniqueID); model.Field(p => p.SampleID).Editable(false); model.Field(p => p.company_business_name).Editable(false); // disable company name on edit // model.Field(p => p.company_business_name).Editable(false); }) .Read(read => read.Action("GetSpecimenDetail", "Home").Data("FillSearchParms")) .Update(update => update.Action("UpdateSpecimen", "Home").Data("FillUpdateParms")) .Destroy(destroy => destroy.Action("DeleteSpecimen", "Home")) .PageSize(10) .Events(e => { e.RequestEnd("onRequestEnd");}) ) )
Here's the call that fires off the search:
$(document).ready(function () { $("#divSearchSpecimenDetail").attr("style", "display: none;"); $("#SearchBtn").click(function (e) { e.preventDefault(); //debugger; var selectedSpecimen = $('#SpecimenCategory').data("kendoDropDownList").text(); if (selectedSpecimen == "-- Select --") { alert("Please select Specimen Category"); return; } var selectedUnits = $('#Units').data("kendoDropDownList").text(); if (selectedUnits == "") { alert("Please select Units"); return; } var units = defaultDDObj("Units"); var specimenCat = defaultDD("SpecimenCategory"); $("#divSearchSpecimenDetail").attr("style", "display: block;"); //debugger; var grid = $("#SpecimenDetailGrid").data("kendoGrid"); grid.dataSource.read(); grid.refresh(); grid.pager.refresh(); e.preventDefault(); hideColumns(specimenCat); $("#searchbar").data("kendoPanelBar").collapse($("li.k-state-active")); })});I have a Kendo Grid that uses Ajax. I want one of my columns to be unbound and to also use a client template. One hack is to do this:
columns.Template(@<text>Unused</text>).Title("SomeTitle").ClientTemplate("#=myTemplateFunction(data)#");
However, it is definitely a hack. Is there a better way to accomplish using a client template and have an unbound column?
My aim is to delete the row when the Command Destroy column is clicked if the built in Confirmation popup if confirmed.
Want: Click Destroy Column > Confirm OK > ActionReult Triggered
Cannot use auto-sync since aiming at keeping other updates and inserts still require the save to be clicked to commit.
Currently the code will remove the row from the display when it is clicked as is built in.
And only after the save button for the grid is clicked does it trigger the ActionResult "OfficerDestroy" for doing so.
Seems there should be some event in this process that could trigger the ActionResult.
What are the options here for triggering that ActionResult while having a confirmation?
@(Html.Kendo().Grid<NexusPWI.ViewModels.Wizard.gridData>()
.Name("OfficerGrid")
.Columns(c => {
c.Bound(vm => vm.GridId); //Can display for testing purposes
c.Bound(vm => vm.FirstName).Width(50);
c.Bound(vm => vm.LastName).Width(50);
c.Bound(vm => vm.Title).Width(50);
c.Command(command => { command.Destroy(); }).Width(30);
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Navigatable()
.Pageable()
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.ServerOperation(false)
.Events(events => events.Error("officerGrid_error") // Handle the "error" event
.RequestEnd("officerGrid_RequestEnd") // Handle the "RequestEnd" event
.Change("officerGrid_Delete")
)
.Model(model => model.Id(vm => vm.GridId))
.PageSize(1000)
.Create("OfficerCreate", "Wizard")
.Read("OfficerRead", "Wizard")
.Update("OfficerUpdate", "Wizard")
.Destroy("OfficerDestroy", "Wizard")//.AutoSync(true)
))
<script>
function officerGrid_RequestEnd(e) {
if (e.type == "update" || e.type == "create") {
this.read();
}
}
</script>
public ActionResult OfficerDestroy([DataSourceRequest] DataSourceRequest request, IEnumerable<gridData> models)
{//This code works fine
}