GridCommand.Parse Equivalent for DataSourceRequest?

2 posts, 0 answers
  1. Nick
    Nick avatar
    86 posts
    Member since:
    Mar 2008

    Posted 24 Feb 2015 Link to this post

    I'm migrating an application from the old Telerik Mvc controls to the latest UI for ASP.NET MVC wrappers.

    I have a bunch of unit tests that validated the controller actions that the grid calls for data.  A simple example would be:

    Public Sub GetLogEntryData_Passes_Through_Filters_On_Multiple_Columns()
      Dim passedCmd As GridParameters = Nothing
      _adminLogService.Setup(Function(s) s.GetLogEntries(It.IsAny(Of GridParameters))).Returns(_validLogEntries).Callback(Sub(p) passedCmd = p)
      Dim target As New AdminLogController(_adminLogService.Object, Nothing)
      Dim cmd As GridCommand = GridCommand.Parse(1, 10, Nothing, Nothing, "UserName~eq~'test'~and~ControllerName~startswith~'Users'")
      Assert.AreEqual(2, passedCmd.Filters.Count)
    End Sub

    Now that I have replaced the grids and I'm passing a DataSourceRequest instead, I don't suppose there's a similarly handy function that can replace the GridCommand.Parse statement?

  2. Rosen
    Rosen avatar
    3214 posts

    Posted 26 Feb 2015 Link to this post

    Hello Nick,

    Although, it is not available you could build such helper method on your own, similar to the following:

    public static class DataSourceRequestHelper
        public static DataSourceRequest Parse(int page, int pageSize, string orderBy, string groupBy, string filter)
            return new DataSourceRequest
                Page = page,
                PageSize = pageSize,
                Sorts = GridDescriptorSerializer.Deserialize<SortDescriptor>(orderBy),
                Filters = FilterDescriptorFactory.Create(filter),
                Groups = GridDescriptorSerializer.Deserialize<GroupDescriptor>(groupBy)


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. UI for ASP.NET AJAX banner
Back to Top