Grid().DataSource

2 posts, 0 answers
  1. Kaan
    Kaan avatar
    7 posts
    Member since:
    Jul 2016

    Posted 31 Aug Link to this post

    Hi,

    I've over 500+ pages that almost has common DataSource definitions like:

    ......

     .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(Constants.UI.GridPageSize)
                .Events(events => events.Error(Constants.UI.GridErrorMethod))
                .Model(model => model.Id(p => p.ID))
                .Create(update => update.Action(Constants.UI.GridMethods.Create))
                .Read(read => read.Action(Constants.UI.GridMethods.Read))
                .Update(update => update.Action(Constants.UI.GridMethods.Update))
                .Destroy(update => update.Action(Constants.UI.GridMethods.Delete))
            )

     

    I've made an extension (defined in here: http://www.telerik.com/forums/define-a-custom-html-kendo-extension-helper), but I also want to say .CustomDataSource() and manage in one place. How I can do that?

    Thank you.

  2. Kaan
    Kaan avatar
    7 posts
    Member since:
    Jul 2016

    Posted 01 Sep in reply to Kaan Link to this post

    Hi,

    I think I found a solution that a static method that takes "dataSource" as a parameter and process it:

     

    .DataSource(dataSource => SomeMethod(dataSource))

     

    And "SomeMethod" is like:

    public static Kendo.Mvc.UI.Fluent.AjaxDataSourceBuilder<T> SomeMethod<T>(Kendo.Mvc.UI.Fluent.DataSourceBuilder<T> dataSource) where T : class
            {
                var _dataSource =
                    dataSource
                    .Ajax() 

     ........................

                return _dataSource;
            }

     

  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top