When given a legit value on startup, value is not represented.
DateRangePicker:
<
div
class
=
"col-sm-6"
>
<
h6
>Date Filter:</
h6
>
@(Html.Kendo().DateRangePicker()
.Name("daterangepicker")
.HtmlAttributes(new { style = "width: 100%" })
.Events(e => e.Change("onDateRangeChange")))
</
div
>
Form Fields:
<
form
>
<
div
asp-validation-summary
=
"ModelOnly"
class
=
"text-danger"
></
div
>
<
input
type
=
"hidden"
id
=
"customerId"
asp-for
=
"CustomerId"
/>
<
input
type
=
"hidden"
id
=
"customerUniqueId"
asp-for
=
"CustomerUniqueId"
/>
<
input
type
=
"hidden"
id
=
"groupId"
asp-for
=
"GroupId"
/>
<
input
type
=
"hidden"
id
=
"personId"
asp-for
=
"PersonId"
/>
<
input
type
=
"hidden"
id
=
"startDate"
asp-for
=
"StartDate"
/>
<
input type
=
"hidden"
id
=
"endDate"
asp-for
=
"EndDate"
/>
</
form
>
Initialize Script:
$(document).ready(function() {
var startDate = $("#startDate").val();
var endDate = $("#endDate").val();
alert(startDate == null);
alert(endDate == null);
alert("Start - " + startDate);
alert("End - " + endDate);
var dateRangePicker = $("#daterangepicker").data("kendoDateRangePicker");
var range = {
start: startDate,
end: endDate
};
dateRangePicker.range(range);
//dateRangePicker.dateView._current = startDate;
//alert("Start - " + dateRangePicker.range().start);
//alert("End - " + dateRangePicker.range().end);
});
Controller:
model.StartDate = DateTime.Today.Date.AddDays(-10);
model.EndDate = DateTime.Today.Date.AddDays(5);
Sometimes I forget the Razorpages is MVC under the covers. Having the need to build single-page app/responsive type web apps, I chose the following approach, and here is how the guts of the solution is laid out I setup for our team:
Web
- This is the main web app which includes an API
Models
- This project simply holds POCO classes that are passed
Data
This project holds classes that wrap Entity data models with methods for saving/fetching etc
The api uses methods in the classes of this project but accepts & returns objects of types from the Models library
The basic approach is when using controls on a page, eg. some dropdowns, a grid etc
- Initial loading of the user input controls via Ajax calls to the api
- Typically there is one main task on a page, but other things have to be loaded at different times in order to get to the point of doing the main edit/update
- Once the user inputs are provided, the data for the grid can be fetched (via jquery/ajax call to api) and the grid loaded
- jQuery code that is common to doing much of the api calls are setup in a common js library
The great thing about this approach is that it handles 99% of what we need and I don't have to replicate the model classes in something like Typescript or javascript as with other frameworks. The same POCO classes can be referenced both in the api and the razor code. Anyone that has had to replicate models i=from C# into Typescript knows what Im referring to. Yes, I had started out pushing our team to use Angular and we went down that road for over a year. It works, but was overkill for what we need. The "noise" of the various frameworks like Node/NPM and including it within a asp.net core app and the dependencies it has on the build process etc was just too much "noise". So along comes Blazor but alas it wasn't production-ready at the time we needed it. Using Razor pages with the above architecture lets one accomplish much of what one would want from a framework like Angular with a far simpler development stack.
hope this helps
My site has a quick-search field on the main nav. When the user puts a first & last name in the field and hits the search button, they expect to land on my Persons.Index page with a list of filtered people. Can you tell me how to pre-populate the filter with values? Then, have the grid refresh using the filters. I prefer not to do multiple round trips... prefer this to be in place the first time the grid reads.
My Grid
@(Html.Kendo().Grid<
Person
>()
.Name("grid")
.Columns(columns =>
{
columns.Command(command => command
.Custom("Detail")
.Click("goDetail"))
.Width(Glossary.Portal.ButtonWidth);
columns.Bound(p => p.FirstName)
.Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")
.ShowOperators(false)
.SuggestionOperator(FilterType.Contains)));
columns.Bound(p => p.LastName)
.Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")
.ShowOperators(false)
.SuggestionOperator(FilterType.Contains)));
})
.Pageable()
.Sortable()
.Scrollable()
.Filterable(ftb => ftb.Mode(GridFilterMode.Row))
.HtmlAttributes(new { style = "height:550px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("IndexJson", "Patients").Data("gridGetData"))
))
Hi to all,
I would obtain a page that has header and footer fixed respectly top and bottom ancor.
In content insert a Grid, this one have to use all remaining height and use its scrollbar to keep rows.
How can I do this?
Hi,
I have a
kendo-panelbar and for SOME of theirs items I would like to load on demand partial
views, using tagHelper syntax.
For the kendo-tabstrip & tabstrip-item it was very simple by using this sequence:
<tabstrip-item
text="Great Job, Telerik"
asp-action="GetMyPartialView"
asp-controller="FromMyController"
asp-route-id="@Model.MyId">
</tabstrip-item>
Can you
provide me an example to use in the panelbar-item context?
Thanks.
The kendo grid is not displaying the paging footer correctly if the grid is part of a modal dialog (Bootstrap Modal). It only shows one page with the possibility to move to the next one (that's working). As you can see in the attached screenshot kendo_grid_paging_wrong.png.
After a resizing event of the browser - e.g. change browser window size or show developer tool bar (F12), ... - the grid becomes displayed correctly. As you can see in the attached screenshot kendo_grid_paging_right.png.
Is this a kind of an incompatibility or bug? We use this kind of code snipped all the time outsite of modals and they do not experience this behaviour.
The associated code to display this grid is as follows:
@(Html.Kendo().Grid<AccountModel>()
.Name(
"accountGrid"
)
.ToolBar(tlb => {
tlb.Search();
})
.DataSource(dataSource => dataSource
.Ajax()
.FullCrud(
"AccountCrud"
)
.PageSize(5)
)
.Selectable(sel => sel.Enabled(
true
).Type(GridSelectionType.Row))
.Columns(columns =>
{
columns.Bound(i => i.Id).Width(100);
columns.Bound(b => b.Name);
columns.Bound(b => b.LoginName);
columns.Bound(b => b.Description);
})
.DefaultOverview(StringLocalizer)
.Search(search =>
{
search.Field(f => f.Name);
search.Field(f => f.LoginName);
search.Field(f => f.Description);
})
.Pageable(p => p
.PageSizes(
new
[] { 5, 10, 25 })
)
)
Hi to all, I would create a view to show several custom functions before grid, these functions will generate several effect to loading data into a grid.
But I would also a Export Excel button, but not above the grid, but enternally, into a div group that contains other controls.
How can I do this?
I don't want use ToolBar of grid.
Can i call a javascript code for example $("#myGrid").exportExcel(); ? Is it possibile?
Hey,
I know there are ways to automatically validate with a kendo validator on a form. However, when I set a min and max value on a Numeric Text Box, after leaving the text box focus, it automatically corrects the value to said range, so the validation always passes. I may be missing it, but I don't see an option with the Razor helper to disable the autocorrect. Is this an option in the .NetCore version or do I need to override this somehow in javascript? I'd like to avoid that if possible as there are numerous (34 to be exact) numeric text boxes that need similar validation. Below is a sample numeric text box.
@(Html.Kendo().NumericTextBoxFor(x=>x.PlanDefault.EmployerMatchPercentMax).Spinners(false).Value(Model.PlanDefault.EmployerMatchPercentMax ?? 0).Min(0).Max(100).HtmlAttributes(new { @class = "form-control" }))
I have a comboBox
@(Html.Kendo().ComboBox()
.Name("contactTypeDropDownList")
//.DataTextField("Type") ??
//.DataValueField("Type") ??
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetContactTypes", "ListBox");
})
.ServerFiltering(true);
})
.SelectedIndex(0)
the action returns items of enum
public
IActionResult GetContactTypes()
{
var contactTypes =
new
List<ContactTypes>();
contactTypes.Add(ContactTypes.Company);
contactTypes.Add(ContactTypes.Person);
return
Json(contactTypes);
}
this enum contains DataAnnotation with "caption"
public
enum
ContactTypes
{
[Display(Name =
"Società "
)]
Company = 0,
[Display(Name =
"Persona"
)]
Person = 1
}
how can I retrieve this "caption" into DataTextField property?