function
LoadPrefs() {
var
grid = $(
"#Inspections"
).data(
"kendoGrid"
);
var
options = localStorage[
"kendo-grid-options"
];
console.log(JSON.parse(options));
if
(options) {
grid.setOptions(JSON.parse(options));
}
}
function
SavePrefs() {
var
grid = $(
"#Inspections"
).data(
"kendoGrid"
);
var
opts = grid.getOptions();
console.log(opts);
localStorage[
"kendo-grid-options"
] = kendo.stringify(opts);
}
I'm trying to use the MultiSelect widget to show tags on an object and allow the users to add new ones dynamically that will get created as they add them (and linked to the object upon save of the page). I'm basing the work on the following example:
https://demos.telerik.com/kendo-ui/multiselect/addnewitem
However, I'm trying to do this with the ASP.NET Core widget, and I'm running into problems when trying to set up the datasource. It appears I can only add a Read method and cannot add a Create similar to the above linked example.
Is this not supported in the ASP.NET Core version? Or is there a ASP.NET Core example somewhere on the site that I just can't find?
How to create columns dynamically
According to configuration file
<config>
<parameter Name="编号材料" FieldName="MATERIAL" Width="80" Desc="在用" />
<parameter Name="储位编号" FieldName="STORAGEMATRIX" Width="10" Desc="在用" />
<parameter Name="材料类别ID" FieldName="CLASS" Width="10" Desc="在用" />
</config>
<config>
<parameter Name="供应商名称" FieldName="PROVIDERNAME" Width="120" Desc="在用" />
<parameter Name="供应商编号" FieldName="PROVIDERCODE" Width="80" Desc="在用" />
</config>
All,
I am having a heck of a time with a very basic implementation using custom Ajax binding.
My implementation is extremely simple. I have verified that the JSON result is returned as CamalCase (Hence the KendoSerializerSettings).
Please see below.
Controller
public
ActionResult YearRead([DataSourceRequest]DataSourceRequest request)
{
IEnumerable<VehMetaYearDto> years = _metaService.GetYears();
DataSourceResult result = years.ToDataSourceResult(request);
return
Json(result, KendoSerializerSettings);
}
JSON Result
{
"Result": {
"Data": [
{
"Year": 2017,
"IsDeleted": false,
"DeleterUserId": null,
"DeletionTime": null,
"LastModificationTime": null,
"LastModifierUserId": null,
"CreationTime": "2018-10-30T12:15:48.1414343",
"CreatorUserId": null,
"Id": 1
},
{
"Year": 2016,
"IsDeleted": false,
"DeleterUserId": null,
"DeletionTime": null,
"LastModificationTime": null,
"LastModifierUserId": null,
"CreationTime": "2018-10-31T08:14:16.9153819",
"CreatorUserId": null,
"Id": 2
}
],
"Total": 2,
"AggregateResults": null,
"Errors": null
},
"TargetUrl": null,
"Success": true,
"Error": null,
"UnAuthorizedRequest": false,
"__abp": true
}
Razor
@(Html.Kendo().Grid<
VehMetaYearDto
>()
.Name("YearGrid")
.Columns(c =>
{
c.Bound(x => x.Year);
})
.DataSource(d => d
.Ajax()
.Read(r => r.Action("YearRead", "VehMetaAdmin"))
)
)
The grid renders blank sadly.
PS - The code formatting for this forum is very difficult to use
I am using core 2.1. Attempting to use tag-helpers, but documentation is pretty bad.
We have a grid mostly working for when there is an existing object, but I don't see a way to use the grid for something new.
For example, if my page is creating a new client, and I'm using the grid for a list of phone numbers, I don't want the grid to go to the server with new entries (create operations), because the client does not exist yet.
Is there a way to add items to the grid in an offline fashion, then bind the data to the model and post the list back with all the other client information?
I want one endpoint for a "New Client" operation that can perform all the validation in one sweep, including validating phone numbers.
Hi! My app uses Razor Pages and I'm trying to do the following:
1. Open a modal dialog, which is itself a Razor Page with a model.
2. Submit from that modal dialog and call the OnPost method in its model.
When I click submit, it simply closes the dialog and never calls the OnPost method.
Here's my code:
First, the calling page, Customer.cshtml:
@page
@addTagHelper "*, Kendo.Mvc"
@model MySite.Test.CustomerModel
@{
Layout = null;
}
<!DOCTYPE html>
<
html
>
<
head
>
<
meta
name
=
"viewport"
content
=
"width=device-width"
/>
<
title
>Customer</
title
>
<
link
href
=
"//kendo.cdn.telerik.com/2018.3.1017/styles/kendo.bootstrap-v4.min.css"
rel
=
"stylesheet"
/>
<
script
src
=
"https://kendo.cdn.telerik.com/2018.3.1017/js/jquery.min.js"
></
script
>
<
script
src
=
"https://kendo.cdn.telerik.com/2018.3.1017/js/kendo.all.min.js"
></
script
>
<
script
src
=
"https://kendo.cdn.telerik.com/2018.3.1017/js/kendo.aspnetmvc.min.js"
></
script
>
<
script
src
=
"https://demos.telerik.com/aspnet-core/lib/jquery-validation/jquery.validate.js"
></
script
>
<
script
src
=
"https://demos.telerik.com/aspnet-core/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"
></
script
>
<
script
src
=
"https://kendo.cdn.telerik.com/2018.3.1017/js/kendo.timezones.min.js"
></
script
>
</
head
>
<
body
>
@{
string[] actions = new string[] { "Close" };
}
<
kendo-window
name
=
"window"
modal
=
"true"
,
title
=
"Add a New Customer"
draggable
=
"true"
resizable
=
"true"
width
=
"800"
,
on-close
=
"onClose"
,
style
=
"display:none"
,
content-url
=
"@Url.Content("
/Test/AddCustomer")" ,
actions
=
"actions"
>
<
content
>
loading user info...
</
content
>
<
popup-animation
enabled
=
"true"
/>
</
kendo-window
>
<
button
id
=
"undo"
class
=
"btn btn-sm btn-outline-primary right"
>Click here to open the window.</
button
>
<
div
class
=
"responsive-message"
></
div
>
<
script
>
function onClose() {
$("#undo").show();
}
$(document).ready(function () {
$("#undo").bind("click", function () {
$("#window").data("kendoWindow").open();
$("#window").data("kendoWindow").center();
$("#undo").hide();
});
});
</
script
>
</
body
>
</
html
>
It has a trivial page model, which I will not include here.
Then the Modal Dialog Page, AddCustomer.cshtml:
@page
@addTagHelper "*, Kendo.Mvc"
@model MySite.Test.AddCustomerModel
@{
Layout = "";
}
<
div
class
=
"container-fluid body-content"
>
<
form
method
=
"post"
>
<
div
asp-validation-summary
=
"All"
class
=
"text-danger"
></
div
>
<
div
class
=
"form-group"
>
<
label
asp-for
=
"Customer.FirstName"
class
=
"control-label"
></
label
>
<
input
asp-for
=
"Customer.FirstName"
class
=
"form-control"
autofocus />
<
span
asp-validation-for
=
"Customer.FirstName"
class
=
"text-danger"
></
span
>
</
div
>
<
div
class
=
"form-group"
>
<
label
asp-for
=
"Customer.Middle"
class
=
"control-label"
></
label
>
<
input
asp-for
=
"Customer.Middle"
class
=
"form-control"
/>
<
span
asp-validation-for
=
"Customer.Middle"
class
=
"text-danger"
></
span
>
</
div
>
<
div
class
=
"form-group"
>
<
label
asp-for
=
"Customer.LastName"
class
=
"control-label"
></
label
>
<
input
asp-for
=
"Customer.LastName"
class
=
"form-control"
/>
<
span
asp-validation-for
=
"Customer.LastName"
class
=
"text-danger"
></
span
>
</
div
>
<
div
class
=
"form-group"
>
<
input
type
=
"submit"
value
=
"Create"
class
=
"btn btn-primary"
/>
</
div
>
</
form
>
</
div
>
and its non-trivial model, which contains the OnPost that is never being called:
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace MySite.Test
{
public class AddCustomerModel : PageModel
{
[BindProperty]
public AddCustomerViewModel Customer { get; set; }
public void OnGet()
{
Customer = new AddCustomerViewModel();
}
public ActionResult OnPost()
{
// I am never getting to this method.
if (ModelState.IsValid)
{
// Do some stuff
return Redirect("/Test/Customer");
}
return Page();
}
public class AddCustomerViewModel
{
[MaxLength(256)]
[Display(Name = "First Name")]
[Required]
public string FirstName { get; set; }
[MaxLength(256)]
[Display(Name = "Middle Name")]
[Required]
public string Middle { get; set; }
[MaxLength(256)]
[Display(Name = "Last Name")]
[Required]
public string LastName { get; set; }
}
}
}
I'm kinda stumped and the only example I can fine is for Razor Views, not Razor Pages. Please advise.
Thanks!
Hello,
With the new Material Theme, how can we have floating labels on Telerik controls (dropdownlist, combobox, ...) ?
Hello,
Since I do not want a static value in my gauge, I want to use some model value. By checking the documentation of the gauge, there is none example to bind it with a model. Is there any example to perform this in asp.net core?
Kind regards.
Hello,
Ive been using multiple graphs now. Those are: bar, scatter and gauge. Now I when I resize my screen and reload my page. The bar and scatter chart will resize perfectly. Only the gauge will keep doing his own thing. How can I fix this, and could this be a feature to add so the scatter will resize when the page reloads/resizes.
Kind regards.