Manipulation of data after ToDataSourceResult

4 posts, 1 answers
  1. Ed
    Ed avatar
    168 posts
    Member since:
    Sep 2013

    Posted 16 Apr 2014 Link to this post

    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.
  2. Answer
    Petur Subev
    Petur Subev avatar
    1882 posts

    Posted 18 Apr 2014 Link to this post

    Hello Ed,

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

    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.

    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
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. RMP
    RMP avatar
    1 posts
    Member since:
    Jul 2015

    Posted 19 Sep 2016 in reply to Petur Subev Link to this post

    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.

  4. Konstantin Dikov
    Konstantin Dikov avatar
    2447 posts

    Posted 21 Sep 2016 Link to this post

    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.
Back to Top