Hi, I am trying Kendo UI for MVc for first time. I am trying to bind a dropdownlist on change event of another dropdownlist.
Here is what I have in view:
<tr> <td style="width:20%">Country</td> <td style="width:30%"> @(Html.Kendo().DropDownListFor(model => model.CommunicationDetailsViewModel[i].CountryId).DataTextField("CountryName").DataValueField("Id").BindTo(Model.CommunicationDetailsViewModel[i].Country).HtmlAttributes(new { style = "width:280px" }) .Events(e => e.Change("country_Change")) .Name("ddlCountry")) </td> <td style="width:20%"></td> <td style="width:30%"></td> </tr> <tr> <td style="width:20%">State</td> <td> @(Html.Kendo().DropDownListFor(model => model.CommunicationDetailsViewModel[i].StateId).DataTextField("StateName").DataValueField("Id").BindTo(Model.CommunicationDetailsViewModel[i].State).HtmlAttributes(new { style = "width:280px" }) .Events(e => e.Change("state_Change")) .Name("ddlState") .CascadeFrom("ddlCountry")) </td> <td style="width:20%"></td> <td style="width:30%"></td> </tr>And I am trying to bind the ddlState dropdownlist using ajax like below:
function country_Change() { $.ajax({ type: 'GET', url: '/api/v1/State/GetStatesFromCountry', dataType: 'json', data: { countryId : $("#ddlCountry").val() }, success: function (states) { $.each(states, function (i, state) { $("#ddlState").append('<option value="' + state.id + '">' + state.stateName + '</option>'); }); }, error: function (ex) { alert('Failed to retrieve states.' + ex); } });}For Now I have 3 countries in table. On page load, all countries can be seen in the country dropdown and its related states in state dropdown. But after Change event occurs, the default value from state dropdown remains as it is, whereas I was expecting it to be filled by states from other countries.
What am I doing wrong?
I have a listview that I need to create a filter for when a user clicks on a button. The filter it needs to add is very complex and I am at a loss as to how to implement it. The application I am building is taking an existing Access database application and converting it to MVC. The filter they used in Access is below. How can I convert this to work in the function at the bottom? I have several filters like this to figure out so I greatly appreciate any help you can give me.
"(((UM)='yes') AND ((FINDATE) Is Not Null) AND ((INVMANDATE) Is Null)) OR (((STKCLASS)='yes') AND ((FINDATE) Is Not Null) AND ((INVMANDATE) Is Null)) OR (((COMMCODE)='yes') AND ((FINDATE) Is Not Null) AND ((INVMANDATE) Is Null)) OR (((COMMONINV)='yes') AND ((FINDATE) Is Not Null) AND ((INVMANDATE) Is Null)) OR (((UM)<>'YES') AND ((STKCLASS)<>'YES') AND ((COMMCODE)<>'YES') AND ((COMMONINV)<>'YES') AND ((INVCTLDATE) Is Not Null) AND ((INVMANDATE) Is Null)) OR (((UM)<>'YES') AND ((STKCLASS)<>'YES') AND ((COMMCODE)<>'YES') AND ((COMMONINV)<>'YES') AND ((REQDATE) Is Not Null) AND ((INVMANDATE) Is Null))"
function filterListview() {
var listView = $("#lvInvMan").data("kendoListView");
listView.dataSource.filter({});
var currentFilters = [], filter;
var myfilter = {
logic: "and",
filters: currentFilters
};
listView.dataSource.filter(myfilter);
}
Yo, so im using the trail version of Telerik and doing some R&D to check if the telerik controls would suit our dev environment.
I have a mvc grid on a view, the grid has an additional action button column using the ClientTemplate(), in this column i render image button which has javascript function linked to the click event which also passes the Grid Id as a parameter. and depending on an active status bound to the grid this also decides what image buttons are displayed.
@(Html.Kendo().Grid<Presentation.AccountGridViewModel>() .Name("Grid") .Columns(columns => { columns.Select().Width(31); columns.Bound(o => o.Id).Groupable(false).Visible(false); columns.Bound(o => o.Name); columns.Bound(o => o.LastUpdated); columns.Bound(o => o.Active); columns.Bound(o => o.Id).ClientTemplate("<img class='grid-button gb-update' src='../Images/icons/update.png' onclick='update(#=Id#)' title='Update'/>" + "#if(Active){#<img class='grid-button gb-delete' src='../Images/icons/delete.png' onclick='deactivate(#=Id#)' title='Delete'/>#}#") .Width(100) .Title("Actions") .Filterable(false); }) .Pageable(pager => pager.AlwaysVisible(true).ButtonCount(5).PageSizes(new List<object> { 5, 10, 20, 100 })) .Sortable() .Filterable() .Scrollable() .PersistSelection() .Events(ev => ev.Change("onChange")) .ClientDetailTemplateId("template") .HtmlAttributes(new { style = "height: 500px;margin-top:40px;" }) .DataSource(d => d .Ajax() .Model(a => a.Id(p => p.Id)) .Read(read => read.Action("CustomAjaxBinding_Read", "Setting")) .PageSize(20) ))I have also instantiated a very basic window on the page and the rest i control via javascript.
@(Html.Kendo().Window() .Name("window") .Width(650) .Height(500) .Visible(false) .Actions(actions => actions.Maximize().Close()) .Draggable())
When the grid button is clicked the javascript function i have opens the window with out any issue,sets the title and centers the window. the problem i am having is how do i dynamically render a MVC partial view inside of the window. loading static content is no issue. is there a javascript equivalent to LoadContentFrom() for the MVC control?
The request should pass the Id parameter from the javascript function to a MVC PartialViewResult action and render the partial view within the Telerik window.
function update(Id) { $("#window").data("kendoWindow") .center() .title('Update Account') .content("your current ID is : "+ Id) // .LoadContentFrom("Test", "Setting") .open();}
The end goal here is to display a form within the window that will allow me to update the record and close the window once the save button is clicked and the grid will also be refreshed to display the updated values.
Thanks in advance

Hi, I have been trying to change the label steps of my category axis but I cannot find a way in the API to do this except for setting the steps to a fixed number .Labels(label => label.Step(12)).
Is there some built in way to do this or should I create a javascript function that returns the steps and then try to access that inside the razor expression?
Hi,
I have a grid where I want a link in some of the cells in one column. The logic for deciding the link is quite complex, so I wanted to have that logic in the read method for the grid in the controller. It was a bad idea for some reasons, but the strange thing is that the update and destroy methods of the grid stopped working. They were not called at all.
I fooled around a bit and found that if you have a property in the view model that is not even shown in the grid and you have a link in that property the update and destroy methods stop working - they are not called.
The project is quite large, so I have attached only the relevant code snippets. You should be able to test just by adding a string property in any view model and set the value to a link like it is done in the example.
My question is: Is this the desired behaviour of the grid or if I have stumbled on a bug.
Best regards,
Henrik
Hi
I have a RadGrid with AllowPaging = "True" and PageSize="20", On the OnItemDataBound method I make some rows (e.Item) Display = false.
However the paging totals and the items per page are now incorrect. The totals do not take into account the fact that some rows are now invisible and the number of items per page which was 20 now does not have that amount because some are invisible.
My question is how do I achieve the correct total and how do I get 20 items or rows a page

I want to be able to conditionally disable selection of a row based on another column on that row. For example, I don't want to allow the user to select a row if a certain column is null.
I know how to conditionally set row and column attributes on data bound so think it's probably here but not sure what's next
function dataBound(e) { var rows = e.sender.tbody.children(); for (var j = 0; j < rows.length; j++) { var row = $(rows[j]); var dataItem = e.sender.dataItem(row); // Disable the checkbox if the location isn't set if (dataItem.get("Location") === "") { row.css('background-color', '#FFFFCF'); // What goes here? } } items = null;}
I also tried to do this on the change event, which kind of work, but the selected IDs (selectedKeyNames) were still being set when the select all checkbox was clicked.
function onChange(e) { var i = e.sender.select(); var grid = e.sender; i.each(function (i, e) { var dataItem = grid.dataItem(e); if (dataItem.get("Location") !== "") { $(e).removeClass("k-state-selected"); } }); items = this.selectedKeyNames();}
Hi,
My grid has a column called Merchant which is supposed to turn into a dropdown list on edit.
For some reason, The initial selected value doesn't connect to the column- does not appear as selected. And when I save on update- The value of the merchant doesn't get the changes on server side- it stays with initial value!!!.
This is the grid:
@(Html.Kendo().Grid<DefaultLimitViewModel>
()
.Name("DefaultLimitsGrid")
.Columns(columns =>
{
columns.Bound(o => o.Id).Hidden();
columns.Bound(o => o.DateLimitId).Hidden();
columns.Bound(o => o.Merchant.MerchantName).EditorTemplateName("MerchantEditor").Title("Merchant").Width(150);
columns.Bound(o => o.Rail).EditorTemplateName("RailEditor").Title("Rail").Width(150);
columns.Bound(o => o.DefaultAmount).Format("{0:c}");
columns.Command(command => { command.Edit().CancelText(" ").UpdateText(" ").Text(" "); command.Destroy().Text(" "); }).Width(200);
})
.ToolBar(toolBar => toolBar.Create())
.Sortable()
.Pageable(x => { x.AlwaysVisible(false); })
.Scrollable()
.Editable(editable => editable.Mode(GridEditMode.InLine))
.HtmlAttributes(new { style = "height:600px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(8)
.Read(read => read.Action("Get_LimitsDefaultData", "Limits"))
.Update(update => update.Action("UpdateDefaultLimit", "Limits"))
.Destroy(Delete => Delete.Action("DeleteDefaultLimit", "Limits"))
.Create(Create => Create.Action("CreateNewDefaultLimit", "Limits"))
.Model(
model =>
{
model.Id(item => item.DateLimitId);
})
)
)
This is the MerchantEditor
@(Html.Kendo().DropDownList()
.Name("Merchant")
.DataValueField("MerchantId")
.DataTextField("MerchantName")
.DataSource(d => d.Read("Merchants_Read", "Limits")))
this is the Merchans_Read function:
public IActionResult Merchants_Read()
{
using (var db = Db.Open())
{
var merchants = db.Select<Merchant>().OrderBy(x => x.Name).Select(mm => new MerchantModel { MerchantId = mm.Id, MerchantName = mm.Name }).ToList();
return Json(merchants);
}
}

Telerik UI for ASP.NET MVC
I have wrongly assumed that the ListBox would work the same or similar to the grid.
I have created and populated a ListBox
cshtml..
@(Html.Kendo().ListBox() .Name(componentName: "lstRewindRolls") .Selectable(ListBoxSelectable.Single) .HtmlAttributes(new { tabindex = -1, @class = "k-listbox", style = "background-color:black; color:white; height:450px" }) .DataValueField("DoffID") .DataTextField("RollID") .DataSource(dataSource => dataSource .Read(read => read.Action(actionName: "GetRolls", controllerName: "Rewind").Data("{ DispositionCode: 'R' }")) ) .Events(events=> events.Change("RewindRollSelected")))
controller...
public JsonResult GetRolls(string DispositionCode){ try { var result = db.tblRolls.Where(r => r.strDispositionCode == DispositionCode && r.dtmInventoryRemoved == null) .Join(db.tblProductSKUs, p => p.lngProductSKUID, q => q.lngProductSKUID, (r, q) => new { r, q }) .Join(db.tblProducts, s => s.q.lngProductID, t => t.lngProductID, (s, t) => new { s, t }) .Select(o => new { DoffID = o.s.r.lngDoffID.ToString(), LaneID = o.s.r.strLaneID, RollID = o.s.r.lngDoffID.ToString() + o.s.r.strLaneID }).OrderBy(t => new { t.DoffID, t.LaneID }).ToList(); ; return Json(result, JsonRequestBehavior.AllowGet); } catch (Exception ex) { ... }
When the page loads the ListBox is populated as expected.
Once I have processed an item in the list, if appropriate (the disposition changed) I want it removed from the list.
I thought I could simply do a dataSource.read()
var lstBox = $("#lstRewindRolls").data("kendoListBox");lstBox.dataSource.read();
I also tried
var lstBox = $("#lstRewindRolls").data("kendoListBox");lstBox.dataSource.read({ DispositionCode: 'R' });
I cannot seem to get it to work.
Please help.
