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

Manipulation of data after ToDataSourceResult

3 Answers 145 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ed
Top achievements
Rank 1
Ed asked on 16 Apr 2014, 11:38 PM
Using Kendo UI MVC Extensions and my grid retrieves several thousand records from the DB and I call ToDataSourceResult to do all the filtering, sorting, Skip/Take, etc.  I want to do some processing of the data in one of the columns after the call to ToDataSourceResult, specifically because I only want to process the data visible to the user (not all several thousand records).  The function I want to use takes the content of the column as a string and returns the formatted data as a string.  Is there a "Kendo UI" way to do this?

Thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Accepted
Petur Subev
Telerik team
answered on 18 Apr 2014, 12:39 PM
Hello Ed,

Basically you can either use a template column which will take care of the formatting:

http://docs.telerik.com/kendo-ui/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/faq#how-do-i-use-a-javascript-function-in-a-column-client-template?

Or you can use the mapping C# function which will be used to project the collection before it is serialized and send to the client.

e.g.
people.ToDataSourceResult(dsRequest, map => new { Fullname = string.Format("Full name is {0} {1}", map.FirstName, map.LastName})

I hope this helps.

Kind Regards,
Petur Subev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
RMP
Top achievements
Rank 1
answered on 19 Sep 2016, 06:01 PM

How can I apply any of these alternatives to my scenario: we have a column that is the cumulative sum of the values of another column, in the VISIBLE rows.

E.g. if I have 3 rows with values 1, 4, 8, the column I want will have the value 1 (first row's value), 5 (second row = 4 [value of second row] + 1 [cumulative value from first row]) and 13 (third row = 8 [value from third row] + 5 [cumulative result from second row]).

The problem is that the cumulative sum must be performed AFTER any filtering is applied, that is, after ToDataSourceResult() call.

How can I achieve it? I can do it before the call, as I have access to writable data, using a cycle through the entire contents. But, then, ToDataSourceResult() is called and I end up with a read-only IEnumerable.

Thank you for your help.

0
Konstantin Dikov
Telerik team
answered on 21 Sep 2016, 06:29 AM
Hi Rui,

Please refer to the answer in the support ticket that you have opened with the same question. If further assistance is needed I would suggest that we continue the conversation within the support ticket. 

For other convenience, the data of the DataSourceResult is within its Data property, which allows further manipulation of the items.


Best Regards,
Konstantin Dikov
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
Tags
Grid
Asked by
Ed
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
RMP
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or