Problems with Grid using SignalR and ServerFiltering, Sorting and Paging

9 posts, 1 answers
  1. Nervia
    Nervia avatar
    4 posts
    Member since:
    Nov 2007

    Posted 02 Jul 2014 Link to this post

    Hello,
    I am developing a Kendo grid using SignalR, this grid is only to read de data, and other enviroment is creating new lines and the hub raise this create method.
    It is working fine without .ServerPaging(true),  .ServerFiltering(true), .ServerSorting(true)
    @(Html.Kendo().Grid<StatScanModeHubModel>()    .Name("Grid")        .Pageable(a=>a
                .PageSizes(new []{100,200,500})            .Refresh(true))        .Navigatable()        .Sortable()        .Filterable()        .DataSource(dataSource => dataSource
            .SignalR()                .ServerPaging(true)                .ServerFiltering(true)                .ServerSorting(true)                .Sort(sort => sort.Add(a => a.Created).Descending())                .PageSize(100)        .Transport(tr => tr
                .Promise("hubStart")            .Hub("hub")            .Client(c => c                .Read("read")                .Create("create"))            .Server(s => s                .Read("read")                .Create("create"))                )        .Schema(schema => schema            .Model(model => model.Id(a => a.StatScanModeId))        )    )

    Hub Code:    public class StatScanModeHub : Hub    {
            public string Read([DataSourceRequest]DataSourceRequest request)        {            DataSourceResult returnList;
                using (var managerService = new ManagerService())            {                var results = managerService.StatScanModeManager.GetAll();                returnList = results.ToDataSourceResult(request,                    Mapper.Map<StatScanMode, StatScanModeHubModel>);                //returnList = Mapper.Map<IEnumerable<StatScanMode>, IEnumerable<StatScanModeHubModel>>(results2);            }            return Newtonsoft.Json.JsonConvert.SerializeObject(returnList);        }
            public StatScanModeHubModel Create(StatScanModeHubModel statScanMode)        {            Clients.Others.create(statScanMode);            return statScanMode;        }

    But when I activate .ServerPaging(true),  .ServerFiltering(true), .ServerSorting(true)In the Hub, the parameter request does not recieve the data to filter, sort... only tha paging parameter.

    Please could someone help me to guide about how I can develop this functionality?
  2. Nervia
    Nervia avatar
    4 posts
    Member since:
    Nov 2007

    Posted 02 Jul 2014 Link to this post

    Excuse me, I haven't used a correct format in previous post.
    Hello,
    I am developing a Kendo grid using SignalR, this grid is only to read de data, and other enviroment is creating new lines and the hub raise this create method.
    It is working fine without .ServerPaging(true),  .ServerFiltering(true), .ServerSorting(true)
    @(Html.Kendo().Grid<StatScanModeHubModel>()
        .Name("Grid")
            .Pageable(a=>a
                .PageSizes(new []{100,200,500})
                .Refresh(true))
            .Navigatable()
            .Sortable()
            .Filterable()
            .DataSource(dataSource => dataSource
            .SignalR()
                    .ServerPaging(true)
                    .ServerFiltering(true)
                    .ServerSorting(true)
                    .Sort(sort => sort.Add(a => a.Created).Descending())
                    .PageSize(100)
            .Transport(tr => tr
                .Promise("hubStart")
                .Hub("hub")
                .Client(c => c
                    .Read("read")
                    .Create("create"))
                .Server(s => s
                    .Read("read")
                    .Create("create"))
                    )
            .Schema(schema => schema
                .Model(model => model.Id(a => a.StatScanModeId))
            )
        )
    Hub Code:
    public class StatScanModeHub : Hub
        {
     
            public string Read([DataSourceRequest]DataSourceRequest request)
            {
                DataSourceResult returnList;
                using (var managerService = new ManagerService())
                {
                    var results = managerService.StatScanModeManager.GetAll();
                    returnList = results.ToDataSourceResult(request,
                        Mapper.Map<StatScanMode, StatScanModeHubModel>);
                    //returnList = Mapper.Map<IEnumerable<StatScanMode>, IEnumerable<StatScanModeHubModel>>(results2);
                }
                return Newtonsoft.Json.JsonConvert.SerializeObject(returnList);
            }
     
            public StatScanModeHubModel Create(StatScanModeHubModel statScanMode)
            {
                Clients.Others.create(statScanMode);
                return statScanMode;
            }
    But when I activate .ServerPaging(true),  .ServerFiltering(true), .ServerSorting(true)In the Hub, the parameter request does not recieve the data to filter, sort... only tha paging parameter.

    Please could someone help me to guide about how I can develop this functionality?
  3. Kendo UI is VS 2017 Ready
  4. Answer
    Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 04 Jul 2014 Link to this post

    Hi Roberto,

    For convenience I created small example which demonstrates how to implement SignalR binding with server operations using the Kendo.DynamicLinq - you can find it attached to the current thread.

    Regards,
    Vladimir Iliev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  5. Greg
    Greg avatar
    1 posts
    Member since:
    Oct 2013

    Posted 21 Apr 2015 in reply to Vladimir Iliev Link to this post

    I have had a play with this sample, but I dont see how you would adjust the filter to take value dynamically from the page, eg an edit box, in the line

     .Filter(f => f.Add(m => m.UnitPrice).IsGreaterThanOrEqualTo(10))

     what if you dont want 10 hard coded?

    In the AJAX implementation, there is a Data() function on the CrudOperation that can run javascript.

     The result of which gets passed into the method on the Controller method. Very flexible and powerful. Could that be provided for the SignalR implementation?

     

    Thanks

    Greg

  6. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 21 Apr 2015 Link to this post

    Hi Greg,

    In the Grid MVC wrapper you can define custom "parameterMap" function in which to include the desired additional parameters back to the server side. Please check the example below:

    .Transport(tr => tr
              .ParameterMap("parameterMap")
              .Promise("hubStart")
              .Hub("hub")
              .Client(c => c

    function parameterMap(data, type) {
        if (type === "read") {
            data.filter = { logic: "and", filters: [{ field: "UnitPrice", operator: "eq", value: 10 }] };
        }
     
        return data;
    }


    Regards,
    Vladimir Iliev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  7. anthony
    anthony avatar
    6 posts
    Member since:
    Apr 2013

    Posted 15 Aug 2015 in reply to Vladimir Iliev Link to this post

    Sorry for resurrecting this old thread, but I have wasted a ton of time today trying to figure out something related to this. 

    Sorting does NOT work in the example you uploaded. If I put a breakpoint on the hub function, then i always get NULL for sorting.

     PS: i did add .ServerSorting(true)...

     

  8. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 18 Aug 2015 Link to this post

    Hi Anthony,

    I tried to reproduce the described behavior but everything is working as expected on our side as seen in this screencast. Could you please elaborate more on what is the exact configuration that you are using and how to reproduce the described behavior on our side?

    Regards,
    Vladimir Iliev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  9. Srinivas
    Srinivas avatar
    2 posts
    Member since:
    Aug 2015

    Posted 06 Jan in reply to Vladimir Iliev Link to this post

    Sorry for bringing this thread back from the dead.

     Your example is the only one I could find that has Razor syntax for the signalR grid however there are some issues I am facing:

     

    The link on the main page to open another browser window instead opens a window which says unknown protocol.

     The Update/Delete/Create methods do not work with two instances of the browser open. I am using Firefox latest stable version (41).

    Please let me know how to fix this as I am attempting to implement signalR via Razor syntax in an app I am working on.

    Thanks
  10. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 08 Jan Link to this post

    Hello Srinivas,

    Please check the answers of your questions below:

    1) To fix the link issue remove the "href" attribute text

    2) The Update / Destroy / Create actions are not working due to invalid configuration (thank you for noting this). Please check the updated methods below:

    public void Update(ProductViewModel product)
    {
        productService.Update(product);
        Clients.Others.update(new {Data = new List<ProductViewModel>() { product } });
    }
     
    public void Destroy(ProductViewModel product)
    {
        productService.Destroy(product);
        Clients.Others.destroy(new { Data = new List<ProductViewModel>() { product } });
    }
     
    public Object Create(ProductViewModel product)
    {
        productService.Create(product);
        Clients.Others.create(new { Data = new List<ProductViewModel>() { product } });
        return new { Data = new List<ProductViewModel>() { product } };
    }

    Regards,
    Vladimir Iliev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready