Telerik Forums
UI for ASP.NET MVC Forum
1 answer
232 views

Updated on Sept 26, 2016: The issue has been resolved in the today's release 2016.3.926.0 of the Telerik ASP.NET MVC VSExtension.

There is an issue with the latest version 2016.3.909.0 of the Telerik MVC VS Extensions, which causes error message to be shown twice during an upgrade.



The problem occurs only if the solution item is selected in the Visual Studio Solution Explorer before running the Upgrade wizard.



If the problem happens, you could simply close and ignore the error messages and the upgrade process will complete normally.

These errors will not show at all if you select a project item instead and then run the Upgrade wizard.

We are working on the fix which will be released soon to the Visual Studio Gallery.

Rumen
Telerik team
 answered on 26 Sep 2016
1 answer
408 views

Say I have a master grid with a nested grid defined via a detail template, and that detail grid has popup editing enabled.
Now, if the master grid has a column with e.g. 'MaxDetailRows' to determine the maximum number of records that can be added in the detail grid - how can I check that the number or rows in the detail grid during editing does not exceed the value held in MaxDetailRows.

Here is the edit event code I have as a start :

function onEditDetailGrid(e) {
 
    //get editor window object
    var kendoWindow = e.container.data("kendoWindow");
 
    if (e.model.isNew()) {
 
        // ==> Here I would like to read the master grid's row, and read a column/cellvalue (e.g. 'MaxDetailRows')
                      if (number of rows in the detail grid == MaxDetailRows)

                      {

                                   return false;

                      }

        kendoWindow.setOptions({
            title: "New Detail Record"
        });
    }
     
}



Thanks in advance,

Mike

Eyup
Telerik team
 answered on 26 Sep 2016
1 answer
589 views

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

Konstantin Dikov
Telerik team
 answered on 26 Sep 2016
7 answers
619 views

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))
)

Maria Ilieva
Telerik team
 answered on 26 Sep 2016
4 answers
166 views
Is there a way to limit the scheduler datasource to only query the server based on the current view and then re-query when the view changes?  For example, if the calendar is currently on month view for October, then I'd like to only have the October events.  When the users changes to a different month, then the datasource should query the server for the events in that month.   The reason I'd like this is because as you get more and more events on the calendar, it starts to take awhile to load. 


Thanks
Rosen
Telerik team
 answered on 26 Sep 2016
4 answers
872 views

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

Bernd
Top achievements
Rank 2
 answered on 23 Sep 2016
3 answers
358 views

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%" })
)
The problem is while saving the date it gets saved as shown in the attachment.

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

 

Eduardo Serra
Telerik team
 answered on 22 Sep 2016
1 answer
193 views
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

Dimitar
Telerik team
 answered on 22 Sep 2016
1 answer
216 views

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! :)

 

 

Eyup
Telerik team
 answered on 22 Sep 2016
9 answers
1.7K+ views
Hi,
My goal is to save the grid settings (filter, sort, group,page, pagesize) in a cache or in a database and restore it.
I am able to save the grid setting but not able to apply it back. 
I save the grid setting on grid databound call

var grid = $("#DocumentGrid").data().kendoGrid;
var dataSource = grid.dataSource;

var state = {
                page: dataSource.page(),
                pageSize: dataSource.pageSize(),
                sort: dataSource.sort(),
                group: dataSource.group(),
                filter: dataSource.filter()
            };

            $.ajax(
                 "/controller/SaveGridSettings", {
                     data: dataSource.transport.parameterMap(state, "read")
                 });
In the controller, i am saving it in a dictionary where "string" is a GUID and saving the setting as a Kendo.Mvc.UI.DataSourceRequest

Dictionary<string, Kendo.Mvc.UI.DataSourceRequest>

For testing purpose, i created a button click event to apply the settings.
To read the grid setting and apply it, i tried the following and it didn't work
var grid = $("#DocumentGrid").data().kendoGrid;
        var dataSource = grid.dataSource;
        $.get("/controller/GetGridSettings", {
            Id:  id <-- Passed in during the call
        }).done(function (data) {
                         dataSource.query(data);
                      //dataSource.filter(data.Filters);  <-- Also tried this way
                     //dataSource.sort(data.Sorts);
        });
I want to apply the saved setting when the users navigate to different page and come back to the page with the grid and when they log out and log back in.

Any help is appreciated.

Thanks,
Dinesh
Terry
Top achievements
Rank 1
 answered on 21 Sep 2016
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
Upload
ComboBox
MultiSelect
ListView
Window
TabStrip
Menu
Installer and VS Extensions
Spreadsheet
AutoComplete
TreeList
Gantt
PanelBar
NumericTextBox
Filter
ToolTip
Map
Diagram
Button
PivotGrid
Form
ListBox
Splitter
Application
FileManager
Sortable
Calendar
View
MaskedTextBox
PDFViewer
TextBox
Toolbar
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
ListView (Mobile)
Pager
Accessibility
ColorPicker
DateRangePicker
Wizard
Security
Styling
Chat
MediaPlayer
TileLayout
DateInput
Drawer
SplitView
Template
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Licensing
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
DropDownButton
AIPrompt
PropertyGrid
ActionSheet (Mobile)
BulletGraph
Button (Mobile)
Collapsible
Loader
CircularGauge
SkeletonContainer
Popover
HeatMap
Avatar
ColorGradient
CircularProgressBar
SplitButton
StackLayout
TimeDurationPicker
Chip
ChipList
DockManager
ToggleButton
Sankey
OTPInput
ChartWizard
SpeechToTextButton
InlineAIPrompt
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
+? more
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?