This is a migrated thread and some comments may be shown as answers.

Grid().DataSource

1 Answer 87 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kaan
Top achievements
Rank 1
Kaan asked on 31 Aug 2016, 07:39 PM

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.

1 Answer, 1 is accepted

Sort by
0
Kaan
Top achievements
Rank 1
answered on 01 Sep 2016, 05:28 PM

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;
        }

 

Tags
Grid
Asked by
Kaan
Top achievements
Rank 1
Answers by
Kaan
Top achievements
Rank 1
Share this question
or