Hi,
I'm tring to change the border color of my inputs when some filed is required, I did accomplish using a sugestion a found on other thread adding those lines on the css
.k-widget > span.k-invalid,
input.k-invalid
{
border: 1px solid #A90329 !important;
}
.k-tooltip-validation {
visibility: hidden
}
But this seems not to be working for controls like multiselect, combobox or autocomplete controls, do you have any suggestion?
Thnaks
So, I'm trying to see if OData will make the performance a little quicker. At first I had Odata v5 but, as far as I know, the Grid only works with v4 so I downgraded. Working with v4 reduced the number of javascript errors coming back.
However, now I'm stuck. Basically, I get "The query parameter '$count' is not supported.". I know the API works if I take out count and run the URL through POSTMAN.
Can someone help me out?
Here's my grid:
@(Html.Kendo().Grid<
vNPISearch
>()
.Name("npi-grid")
.Columns(columns =>
{
columns.Template(x => { }).ClientTemplate("#=GetPecosStatus(PecosNPI) #").Width(50);
columns.Bound(x => x.ProviderFirstName).Title("First Name");
columns.Bound(x => x.ProviderLastName).Title("Last Name");
columns.Bound(x => x.ProviderBusinessLocationAddressCity).Title("City");
columns.Bound(x => x.ProviderBusinessLocationAddressState).Title("State");
columns.Bound(x => x.NPI).Title("NPI");
})
.DataSource(dataSource => dataSource
.Custom()
.Schema(sch =>
{
sch.Model(m =>
{
m.Id("NPI");
m.Field(f => f.NPI).Editable(false);
m.Field(f => f.ProviderFirstName).Editable(false);
m.Field(f => f.ProviderLastName).Editable(false);
m.Field(f => f.ProviderBusinessLocationAddressCity).Editable(false);
m.Field(f => f.ProviderBusinessLocationAddressState).Editable(false);
});
})
.Type("odata-v4")
.Transport(transport =>
{
transport.Read(read => read.Url("http://localhost:58242/api/PecosSearch/Search?id=" + Model.SearchTerm));
})
.PageSize(20)
.ServerPaging(true)
.ServerSorting(true)
.ServerFiltering(true)
)
.Scrollable(scr => scr.Height("auto"))
.Sortable()
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5))
)
Hello.
I am using the UI for ASP.NET MVC Grid version 2016.3.914.545 with Telerik DataAccess version 2016.1.224.1 with a MSSQLLocalDB for development.
As long as there is no filter or group used in the grid everything is working. If the user filters, even a simple "=", the request times out. Using the DataAccess Profiler I found the reason. The generated SQL statement reads all records. Not only the required 10. Which takes about three minutes with subsequent requests to get the detailed data.
The grid config in my view:
01.
@(Html.Kendo().Grid<CalendarEventViewModel>()
02.
.Name(componentName:
"eventGrid"
)
03.
.Pageable()
04.
.Scrollable(s => { s.Height(value:
"auto"
); s.Enabled(value:
true
); })
05.
.Filterable()
06.
.Groupable()
07.
.Sortable(s => s.Enabled(value:
true
))
08.
.Resizable(r => r.Columns(value:
true
))
09.
.Selectable()
10.
.Columns(columns => {
11.
columns.Bound(c => c.Operation.OperationIdFormatted)
12.
.HeaderHtmlAttributes(
new
{ data_resource_set = ResourceSet.Properties, data_resource_id = $
"{nameof(OperationViewModel)}.{nameof(OperationViewModel.MasterSystemId)}"
})
13.
.Title(Html.GetGlobalResourceString(resourceKey: $
"{nameof(OperationViewModel)}.{nameof(OperationViewModel.MasterSystemId)}"
, resourceSet: ResourceSet.Properties));
14.
columns.Bound(c => c.Title)
15.
.HeaderHtmlAttributes(
new
{ data_resource_set = ResourceSet.Properties, data_resource_id = $
"{nameof(CalendarEventViewModel)}.{nameof(CalendarEventViewModel.Title)}"
})
16.
.Title(Html.GetGlobalResourceString(resourceKey: $
"{nameof(CalendarEventViewModel)}.{nameof(CalendarEventViewModel.Title)}"
, resourceSet: ResourceSet.Properties));
17.
columns.Bound(c => c.Workplace.Label)
18.
.HeaderHtmlAttributes(
new
{ data_resource_set = ResourceSet.Properties, data_resource_id = $
"{nameof(CalendarEventViewModel)}.{nameof(CalendarEventViewModel.Workplace)}"
})
19.
.Title(Html.GetGlobalResourceString(resourceKey: $
"{nameof(CalendarEventViewModel)}.{nameof(CalendarEventViewModel.Workplace)}"
, resourceSet: ResourceSet.Properties));
20.
columns.Bound(c => c.Description)
21.
.HeaderHtmlAttributes(
new
{ data_resource_set = ResourceSet.Properties, data_resource_id = $
"{nameof(CalendarEventViewModel)}.{nameof(CalendarEventViewModel.Description)}"
})
22.
.Title(Html.GetGlobalResourceString(resourceKey: $
"{nameof(CalendarEventViewModel)}.{nameof(CalendarEventViewModel.Description)}"
, resourceSet: ResourceSet.Properties));
23.
columns.Bound(c => c.StartWeek)
24.
.HeaderHtmlAttributes(
new
{ data_resource_set = ResourceSet.Properties, data_resource_id = $
"{nameof(CalendarEventViewModel)}.{nameof(CalendarEventViewModel.StartWeek)}"
})
25.
.Title(Html.GetGlobalResourceString(resourceKey: $
"{nameof(CalendarEventViewModel)}.{nameof(CalendarEventViewModel.StartWeek)}"
, resourceSet: ResourceSet.Properties));
26.
columns.Bound(c => c.EndWeek)
27.
.HeaderHtmlAttributes(
new
{ data_resource_set = ResourceSet.Properties, data_resource_id = $
"{nameof(CalendarEventViewModel)}.{nameof(CalendarEventViewModel.EndWeek)}"
})
28.
.Title(Html.GetGlobalResourceString(resourceKey: $
"{nameof(CalendarEventViewModel)}.{nameof(CalendarEventViewModel.EndWeek)}"
, resourceSet: ResourceSet.Properties));
29.
columns.Bound(c => c.Start).Format(value:
"{0:F}"
)
30.
.HeaderHtmlAttributes(
new
{ data_resource_set = ResourceSet.Properties, data_resource_id = $
"{nameof(CalendarEventViewModel)}.{nameof(CalendarEventViewModel.Start)}"
})
31.
.Title(Html.GetGlobalResourceString(resourceKey: $
"{nameof(CalendarEventViewModel)}.{nameof(CalendarEventViewModel.Start)}"
, resourceSet: ResourceSet.Properties));
32.
columns.Bound(c => c.End).Format(value:
"{0:F}"
)
33.
.HeaderHtmlAttributes(
new
{ data_resource_set = ResourceSet.Properties, data_resource_id = $
"{nameof(CalendarEventViewModel)}.{nameof(CalendarEventViewModel.End)}"
})
34.
.Title(Html.GetGlobalResourceString(resourceKey: $
"{nameof(CalendarEventViewModel)}.{nameof(CalendarEventViewModel.End)}"
, resourceSet: ResourceSet.Properties));
35.
columns.Bound(c => c.Operation.TimeSpanPerUnit)
36.
.HeaderHtmlAttributes(
new
{ data_resource_set = ResourceSet.Properties, data_resource_id = $
"{nameof(OperationViewModel)}.{nameof(OperationViewModel.TimePerUnit)}"
})
37.
.Title(Html.GetGlobalResourceString(resourceKey: $
"{nameof(OperationViewModel)}.{nameof(OperationViewModel.TimePerUnit)}"
, resourceSet: ResourceSet.Properties))
38.
.ClientTemplate(value:
"#if (data.TimeSpanPerUnit) {# #:kendo.toString(TimeSpanPerUnit.Hours, '00')#:#:kendo.toString(TimeSpanPerUnit.Minutes, '00')#:#:kendo.toString(TimeSpanPerUnit.Seconds, '00')# #}#"
);
39.
columns.Bound(c => c.Operation.QuantityToProduce).Format(value:
"{0:n}"
)
40.
.HeaderHtmlAttributes(
new
{ data_resource_set = ResourceSet.Properties, data_resource_id = $
"{nameof(OperationViewModel)}.{nameof(OperationViewModel.QuantityToProduce)}"
})
41.
.Title(Html.GetGlobalResourceString(resourceKey: $
"{nameof(OperationViewModel)}.{nameof(OperationViewModel.QuantityToProduce)}"
, resourceSet: ResourceSet.Properties));
42.
columns.Bound(c => c.Operation.QuantityConfirmed).Format(value:
"{0:n}"
)
43.
.HeaderHtmlAttributes(
new
{ data_resource_set = ResourceSet.Properties, data_resource_id = $
"{nameof(OperationViewModel)}.{nameof(OperationViewModel.QuantityConfirmed)}"
})
44.
.Title(Html.GetGlobalResourceString(resourceKey: $
"{nameof(OperationViewModel)}.{nameof(OperationViewModel.QuantityConfirmed)}"
, resourceSet: ResourceSet.Properties));
45.
columns.Bound(c => c.Operation.QuantityOpen).Format(value:
"{0:n}"
)
46.
.HeaderHtmlAttributes(
new
{ data_resource_set = ResourceSet.Properties, data_resource_id = $
"{nameof(OperationViewModel)}.{nameof(OperationViewModel.QuantityOpen)}"
})
47.
.Title(Html.GetGlobalResourceString(resourceKey: $
"{nameof(OperationViewModel)}.{nameof(OperationViewModel.QuantityOpen)}"
, resourceSet: ResourceSet.Properties));
48.
columns.Bound(c => c.Operation.Length)
49.
.HeaderHtmlAttributes(
new
{ data_resource_set = ResourceSet.Properties, data_resource_id = $
"{nameof(OperationViewModel)}.{nameof(OperationViewModel.Length)}"
})
50.
.Title(Html.GetGlobalResourceString(resourceKey: $
"{nameof(OperationViewModel)}.{nameof(OperationViewModel.Length)}"
, resourceSet: ResourceSet.Properties))
51.
.ClientTemplate(value:
"#if (data.Length) {# #:kendo.toString(Length.Hours, '00')#:#:kendo.toString(Length.Minutes, '00')#:#:kendo.toString(Length.Seconds, '00')# #}#"
)
52.
.EditorTemplateName(templateName:
"TimeSpan"
);
53.
})
54.
.DataSource(d => d.Ajax().Model(m => {
55.
m.Id(f => f.Id);
56.
m.Field(f => f.Id).Editable(enabled:
false
);
57.
})
58.
.Events(e => e.Error(handler:
"scheduler_error"
))
59.
.Read(read => read.Route(SchedulerControllerRoute.PostOperationEvents,
new
RouteValueDictionary { {
"culture"
, UICulture.ToLower() } }))
60.
.Update(update => update.Route(SchedulerControllerRoute.PostUpdate,
new
RouteValueDictionary { {
"culture"
, UICulture.ToLower() } }))
61.
//.Destroy(destroy => destroy.Route(OperationControllerRoute.PostDestroy, new RouteValueDictionary { { "culture", UICulture.ToLower() } }))
62.
.Create(create => create.Route(SchedulerControllerRoute.PostCreate,
new
RouteValueDictionary { {
"culture"
, UICulture.ToLower() } }))
63.
)
64.
.ClientDetailTemplateId(id:
"operationDetailTemplate"
)
65.
.Events(e => e.DataBound(handler:
"dispatcher.onGridDataBound"
))
66.
.Deferred()
67.
)
The read service:
01.
public
IQueryable<CalendarEventViewModel> OperationEvents() {
02.
IQueryable<CalendarEventViewModel> result =
new
CalendarEventViewModel[] { }.AsQueryable();
03.
FetchStrategy oldStrategy = _db.FetchStrategy;
04.
var strategy =
new
FetchStrategy();
05.
strategy.LoadWith<WorkOrder>(w => w.Endproduct);
06.
_db.FetchStrategy = strategy;
07.
PreferenceProfile activeProfile = HttpContext.Current.Session.Get<PreferenceProfile>(SessionKey.ActiveProfile);
08.
if
(activeProfile !=
null
) {
09.
string
masterSystemId = activeProfile.Company.MasterSystemId;
10.
result =_db.CalendarEvents.Where(ce => ce.Operation !=
null
&& ce.Operation.MasterSystemHierarchy==masterSystemId && !filteredStates.Contains(ce.Operation.ProcessingStatus) && ce.Operation.WorkOrder.QuantityToProduce-ce.Operation.QuantityConfirmed > 0)
11.
.Select(ce => _mapper.Map<CalendarEventViewModel>(ce));
12.
}
13.
_db.FetchStrategy = oldStrategy;
14.
return
result;
15.
}
In the controller itself nothing special happens:
1.
public
JsonResult OperationEvents([DataSourceRequest] DataSourceRequest request) {
2.
IQueryable<CalendarEventViewModel> result = ((ISchedulerEventService) crudService).OperationEvents();
3.
return
Json(result.ToDataSourceResult(request));
4.
}
The SQL generated after setting a filter:
01.
SELECT
02.
a.[Id]
AS
COL1,
03.
a.[ActivityStatus]
AS
COL2,
04.
a.[BackgroundColor]
AS
COL3,
05.
a.[EventType]
AS
COL4,
06.
a.[Description]
AS
COL5,
07.
a.[en]
AS
COL6,
08.
a.[EventType]
AS
COL7,
09.
a.[IsAllDay]
AS
COL8,
10.
a.[OperationId]
AS
COL9,
11.
a.[OperationId]
AS
COL10,
12.
a.[RecurrenceException]
AS
COL11,
13.
a.[RecurrenceRule]
AS
COL12,
14.
a.[strt]
AS
COL13,
15.
a.[Status]
AS
COL14,
16.
a.[Title]
AS
COL15,
17.
a.[WorkplaceId]
AS
COL16,
18.
a.[WorkplaceId]
AS
COL17
19.
20.
FROM
[CalendarEvent] a
21.
22.
JOIN
[Operation]
AS
b
23.
ON
(a.[OperationId] = b.[Id])
24.
25.
JOIN
[WorkOrder]
AS
c
26.
ON
(b.[WorkOrderId] = c.[Id])
27.
28.
WHERE
a.[OperationId]
IS
NOT
NULL
29.
AND
b.[MasterSystemHierarchy] = @p0
30.
AND
NOT
((b.[ProcessingStatus]
IN
(@p1, @p2)))
31.
AND
c.[QuantityToProduce] - b.[QuantityConfirmed] > 0
32.
33.
ORDER
BY
COL1
The grid filter, Workplace.Label="Something", is missing and the TOP() statement is missing. Seems Like ToDataSourceResult wants to laod everything into memory and do the filtering itself.
How can I convince ToDataSourceResult from taking only the needed and filterd 10 rows? Does it help if I add the filters in my where clause as request filters?
Side note for the DataAccess team: I configured logging of the stack trace, but the profiler says there is none. My configuration:
config.Logging.LogEvents = LoggingLevel.Verbose;
config.Logging.StackTrace =
true
;
config.Logging.EventStoreCapacity = 10000;
config.Logging.MetricStoreCapacity = 3600;
config.Logging.MetricStoreSnapshotInterval = 1000;
config.Logging.Downloader.EventText =
true
;
config.Logging.Downloader.EventPollSeconds = 1;
config.Logging.Downloader.MetricPollSeconds = 1;
config.Logging.Downloader.Filename =
"C:\\Temp\\OALog"
;
config.Logging.Downloader.EventBinary =
true
;
config.Logging.Downloader.MetricBinary =
true
;
Kind regards
Bernd
Hi,
I am using a date picker to edit the date displayed on my grid.
@(Html.Kendo().DatePicker()
.Name("Date")
.Value("Value")
.Format("MM/dd/yyyy")
.HtmlAttributes(new { style = "width: 30%" })
)
I just want it to be saved in the format (mm/dd/yyyy) and I dont want those extra labels such as indian standard time etc.
Can anyone help?
Regards,
Adhip
Hello, i have a problem with my Grid and Persist-State, when i use "Load" state, the grid lose all properties(Edit and Remove bottons, Tooltips and styles).
This is the Code.
@{
string quote = "\"";
var javaScriptSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
string jsonString = javaScriptSerializer.Serialize(DictionaryByControls.TagsConfirmationPanel);
}
@(Html.Kendo().Grid<
ControlGAS.DataAccess.Entities.Customer
>()
.Name("GridCustomers")
.Columns(columns =>
{
columns.Bound(customer => customer.Id).Title("ID").Filterable(f => f.UI("filterById")).HtmlAttributes(new { @style = "white-space: nowrap;" });
columns.Bound(customer => customer.Denomination).Title(ControlGAS.Office.Resources.Resources.ControlGAS.Denomination).Filterable(f => f.UI("filterByName")).HtmlAttributes(new { @style = "white-space: nowrap;" });
columns.Bound(customer => customer.Code).Title(ControlGAS.Office.Resources.Resources.ControlGAS.Code).Filterable(f => f.UI("filterByCode")).HtmlAttributes(new { @style = "white-space: nowrap;" });
columns.Bound(customer => customer.Address).Title(ControlGAS.Office.Resources.Resources.ControlGAS.Address).Filterable(f => f.UI("filterByAddress")).HtmlAttributes(new { @style = "white-space: nowrap;" });
columns.Bound(customer => customer.City).Title(ControlGAS.Office.Resources.Resources.ControlGAS.City).Filterable(f => f.UI("filterByCity")).HtmlAttributes(new { @style = "white-space: nowrap;" });
columns.Bound(customer => customer.FiscalIdentification).Title(ControlGAS.Office.Resources.Resources.ControlGAS.FiscalIdentification).Filterable(f => f.UI("filterByFiscalId")).HtmlAttributes(new { @style = "white-space: nowrap;" });
columns.Template(customer => { }).ClientTemplate(
"<
a
href
=
" + quote + @Url.Action("
Editing", "Customer", new {
customerId
=
"#=Id#"
}) + quote + "><
i
class
=
'font-size-20 icon md-edit margin-right-10'
aria-hidden
=
'true'
></
i
></
a
>" + "" +
"<
a
class
=
'cursor-pointer'
data-customer
=
'#=Denomination#'
data-id-customer
=
'#=Id#'
data-resource
=
'" + jsonString + "'
data-control
=
'btn-delete-customer'
><
i
class
=
'font-size-20 icon md-delete margin-right-10'
aria-hidden
=
'true'
></
i
></
a
>")
.Title("Actions").Width(100);
})
.ColumnMenu()
.Scrollable(s => s.Height("100%"))
.Sortable()
.Groupable(g => g.Messages(m => m.Empty(ControlGAS.Office.Resources.Resources.ControlGAS.Drag)))
.Pageable(p => p
.Refresh(true)
.PageSizes(true)
.ButtonCount(5)
.PreviousNext(true)
.Messages(m => m.ItemsPerPage(ControlGAS.Office.Resources.Resources.ControlGAS.ItemPerPage)))
.DataSource(
dataSource => dataSource
.Ajax()
.Read(read => read.Action("GetCustomers", "Customer"))
)
.Resizable(r => r.Columns(true))
.Reorderable(r => r.Columns(true))
.ClientDetailTemplateId("master")
.Filterable(filter => filter.Mode(GridFilterMode.Row)
.Extra(false)
.Operators(operators => operators
.ForString(str => str.Clear()
.StartsWith(ControlGAS.Office.Resources.Resources.ControlGAS.StartsWith)
.IsEqualTo(ControlGAS.Office.Resources.Resources.ControlGAS.IsEqualTo)
.IsNotEqualTo(ControlGAS.Office.Resources.Resources.ControlGAS.IsNotEqualTo)
)
.ForNumber(num => num.Clear()
.IsEqualTo(ControlGAS.Office.Resources.Resources.ControlGAS.IsEqualTo)
.IsNotEqualTo(ControlGAS.Office.Resources.Resources.ControlGAS.IsNotEqualTo)
.IsNull(ControlGAS.Office.Resources.Resources.ControlGAS.IsNull)
.IsLessThan(ControlGAS.Office.Resources.Resources.ControlGAS.IsLessThan)
.IsGreaterThan(ControlGAS.Office.Resources.Resources.ControlGAS.IsGreaterThan))
)
)
.Events(events => events.DataBound("dataBound"))
)
Save State
function
GetDataGrid() {
var
grid = $(
"#GridCustomers"
).data(
"kendoGrid"
);
var
dataSource = grid.dataSource;
var
currentColumnState =
new
Array();
for
(
var
i = 0; i < grid.columns.length; i++) {
if
(grid.columns[i].hidden == undefined) {
grid.columns[i].hidden =
false
;
currentColumnState.push({
field: grid.columns[i].field,
hidden: grid.columns[i].hidden
});
}
else
{
currentColumnState.push({
field: grid.columns[i].field,
hidden: grid.columns[i].hidden
});
}
}
var
state = {
page: dataSource.page(),
pageSize: dataSource.pageSize(),
sort: dataSource.sort(),
group: dataSource.group(),
filter: dataSource.filter(),
columns: currentColumnState
};
return
JSON.stringify(state);
}
Load State
function
SetDataGrid(data) {
debugger;
var
result = data.result;
var
jsonResult = $.parseJSON(result);
var
state = $.parseJSON(jsonResult.Data);
var
grid = $(
"#GridCustomers"
).data(
"kendoGrid"
);
var
options = grid.options;
for
(
var
i = 0; i < state.columns.length; i++) {
options.columns[i].hidden = state.columns[i].hidden;
console.log(state.columns[i]);
if
(state.columns[i].hidden ==
true
) {
grid.hideColumn(i);
}
else
{
grid.showColumn(i);
}
}
options.columns = state.columns;
options.dataSource.page = state.page;
options.dataSource.pageSize = state.pageSize;
options.dataSource.sort = state.sort;
options.dataSource.filter = state.filter;
options.dataSource.group = state.group;
grid.destroy();
$(
"#GridCustomers"
).kendoGrid(options);
}
Thanks All
This works:
.Read(read => read.Action("StandardTableReadNull", "DashDataparts", new { AdditionalParam = "foo" })
This doesn't:
.Read(read => read.Action("StandardTableReadNull", "DashDataparts").Data("additionalData")
<
script
>
function additionalData() {
return {
AdditionalParam: "foo"
}
}
</
script
>
In the second example, the script never hit, so the parameter never got populated in our controller. (In both cases, our Read controller action was hit, but the "AdditionalParam" parameter was only populated in the first example)
We tried putting the script in our main js file, putting it on our view page, and putting it directly inline in the .Data call, none of which worked.
Any thoughts why? Any help would be greatly appreciated! :)
Hi,
is there a way (like in PivotGrid for ASP.NET AJAX) to persist a pivot grid on the server.
Usage: the user drags columns around till he has the desired result - with save he can persist this "view" on the server. Later he can recall this "view" to have the same PivotGrid configuration again.
Manfred
Hey Guys
Just busy adding custom validation to my solution and came across this issue.
I used the example of adding custom validation for Dates provided here and change it to support time between and using TimeSpans.
Please ignore how crappy the coding is, I am not a javascript coder, so I just bash my way through it!
IsTimeBetween:
function
(input) {
if
(input.is(
"[data-val-IsTimeBetween]"
) && input.val() !=
""
) {
var
fromtime =input.val();
var
fromtimeAr = fromtime.split(
":"
);
var
fromtimeMin = 0;
fromtimeMin = fromtimeMin + parseInt(fromtimeAr[1]);
fromtimeMin = fromtimeMin + parseInt(fromtimeAr[0] * 60);
console.log(
'validating between'
);
var
lowertime = $(
"[name='"
+ input.attr(
"data-val-IsTimeBetween-lowerproperty"
) +
"']"
).val();
var
lowertimeAr = lowertime.split(
":"
);
var
lowertimeMin = 0;
lowertimeMin = lowertimeMin + parseInt(lowertimeAr[1]);
lowertimeMin = lowertimeMin + parseInt(lowertimeAr[0] * 60);
var
uppertime = $(
"[name='"
+ input.attr(
"data-val-IsTimeBetween-upperproperty"
) +
"']"
).val();
var
uppertimeAr = uppertime.split(
":"
);
var
uppertimeMin = 0;
uppertimeMin = uppertimeMin + parseInt(uppertimeAr[1]);
uppertimeMin = uppertimeMin + parseInt(uppertimeAr[0] * 60);
return
!fromtime || !lowertime || !uppertime || (fromtimeMin > lowertimeMin && fromtimeMin < uppertimeMin);
}
return
true
;
}