Hi There,
I am working on a grid which has a dropdownlist column. I use the solution in the following demo:
https://demos.telerik.com/aspnet-core/grid/editing-custom
The difference is that we need to save the grid through an ajax call instead of the build-in "Save Changes" button. I added a "Save" button under the grid, change the dropdownlist value and use the following code to post the grid data to Controller action, but the value of products passed to Action always contains the original dropdownlist value other than the updated value. Is there anything not right in my code? Please help. Thank you.
$('#btnSaveGridData').click(function () {
var data = $("#grid").data("kendoGrid").dataSource.data();
$.ajax({
url: '/Editing_CustomController/SaveGridData',
type: "post",
contentType: 'application/json',
dataType: 'json',
data: JSON.stringify(data),
complete: function (response) {
$("#gridSection").empty();
$("#gridSection").html(response.responseText);
},
failure: function (response) {
//alert(response.responseText);
},
error: function (response) {
//alert(response.responseText);
}
});
});
Controller Action
[HttpPost]
public async Task<
IActionResult
> SaveGridData([FromBody] List<
ProductViewModel
> products)
{
//Action logic
return PartialView("_Grid");
}
Hi,
We have a custom popup grid editing form with cascading dropdowns, which use serverFiltering(true) and pass 3 parameters to the datasource read action.
The dropdown gets a set of items and we then want to use simple clientside filtering in the dropdown to help the users find what they want:
@(Html.Kendo().DropDownListFor(m => m.CodeId)
.OptionLabel("Select code ...")
.DataTextField("Description")
.DataValueField("Id")
.Filter(FilterType.Contains)
.MinLength(2)
.ValuePrimitive(true)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetCodesForPropertyForCashType", "CodeInvoice").Data("GetCodes");
})
.ServerFiltering(true);
})
.Enable(false)
.AutoBind(false)
.CascadeFrom("ScheduleId")
)
But the server filtering always seems to kick in.
Can we get the dropdown to just filter its contents in place after the initial load?
Thanks,
Daniel.
How create chart with 2 or 3 bars from DataSource
series.Bar(model => model.Sum).Name(""); // One Bar
series.Bar(model => model.Sum).Name(""); // Need new data????
@(Html.Kendo().Chart<CoreDiag.Models.CKassaLine>(Model)
.Name(
"Name1"
)
// The name of the Chart is mandatory. It specifies the "id" attribute of the widget.
.Title(
"Name1"
)
.Series(series =>
{
series.Bar(model => model.Sum).Name(
""
);
})
.CategoryAxis(axis => axis
.Categories(model => model.Period)
)
)
HI
I have a ASP.NET MVC/ASP.NET Core MVC compatibility question
about ASP.NET Core MVC Grid.
Why the following code not available in .NET Core 2.2 ?
.cshtml
columns.Template(template => { }).ClientTemplate(" ");
More detail :
.Columns(columns =>
{
...
columns.Template(template => { }).ClientTemplate(" ");
})
I think Telerik have the responsibility keep the code of recent version
(R2 2017, R2 2019...) to compatible with ASP.NET Core MVC.
Private implementation changed but should try to keep the public property/method the same.
It is the Value/Reason Why We choose Telerik.
Best regards
Chris
I have a situation where I don't know the number of columns I need at design time.
I want to do something like:
DateTime dt = DateTime.Now.Date;
int dayCount = 30;
.Columns(columns =>
{
for (int i = 0; i < dayCount ; i++)
{
columns.Bound(model.datedata).Title(dt.AddDays(i).ToString())… blah blah blah
}
}
Can someone show me an example of how to do this. Nothing I've found on the web seems to fit this bill.
Thanks …. Ed
Hi.
How I can change the value before export data to PDF?
I have a checkbox, and I need to change the format, I want to write YES/NO for checkboxes.
Is it possible to change PDF export to say Yes / No for check-boxes?
Not sure if the drawer is really meant for this, as it seems a bit more like a highly interactive tab control than just being a fly-out. But is there a way to have 2 drawers, one on the left and another on the right?
I'd like to have the left handle navigation, and the right be a fly-out for other various things.
Thanks
I hope this is an easy fix. I have a DropDownList in my Grid which seems to be working fine except the selected value is not being returned to the Controller Action. For example, when I select a new value for "Type" below, it still shows the original value in the model in the Controller. See "<--" NOTES BELOW.
Thanks very much for the help.
*** MODEL ***
public class SelectValueViewModel
{
public int Id { get; set; }
public string Code { get; set; }
public string Description { get; set; }
[UIHint("SelectValuesTypeDropDown")]
public string Type { get; set; } // <-- TRYING TO UPDATE THIS VALUE WITH THE DROP DOWN.
public List<SelectListItem> CodeTypes { get; set; }
}
*** VIEW ***
@(Html.Kendo().Grid<CCMC.View_Models.SelectValueViewModel>()
.Name("SelectValuesGrid")
.Columns(c =>
{
c.Bound(m => m.Code).Width(100);
c.Bound(m => m.Description).Width(100);
c.Bound(m => m.Type).Width(100);
c.Command(command => { command.Edit(); }).Width(200);
c.Command(command => command.Destroy()).Width(150);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable()
.Sortable()
.Scrollable()
// .HtmlAttributes(new { style = "height:550px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Model(model =>
{
model.Id(sv => sv.Type);
// model.Field(sv => sv.Id).Editable(false);
})
.Events(events => events.Error("error_handler"))
.Read(read => read.Action("Read", "SelectValues"))
.Update(update => update.Action("Edit", "SelectValues").Data("sendAntiForgery"))
.Destroy(destroy => destroy.Action("Delete", "SelectValues"))
)
)
*** EDIT TEMPLATE ***
@model CCMC.View_Models.SelectValueViewModel
@(Html.Kendo().DropDownListFor(m => m.Type)
.DataValueField("Value")
.DataTextField("Text")
.BindTo(Model.CodeTypes)
.BindTo((System.Collections.IEnumerable)ViewData["SelectValueTypes"])
)
*** CONTROLLER ***
[AcceptVerbs("Post")]
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<JsonResult> Edit([DataSourceRequest] DataSourceRequest request, SelectValueViewModel model)
{
model.Type // <--- THE VALUE IS NOT UPDATED HERE. STILL HAS THE ORIGINAL VALUE.
}
Hello,
How to select an item by Id or datasorce value?
robert