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

Problems with Grid using SignalR and ServerFiltering, Sorting and Paging

8 Answers 462 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nervia Consultores S.L.
Top achievements
Rank 1
Nervia Consultores S.L. asked on 02 Jul 2014, 02:47 PM
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?

8 Answers, 1 is accepted

Sort by
0
Nervia Consultores S.L.
Top achievements
Rank 1
answered on 02 Jul 2014, 02:54 PM
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?
0
Accepted
Vladimir Iliev
Telerik team
answered on 04 Jul 2014, 07:52 AM
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!
 
0
Greg
Top achievements
Rank 1
answered on 21 Apr 2015, 08:48 AM

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

0
Vladimir Iliev
Telerik team
answered on 21 Apr 2015, 01:26 PM
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!
 
0
anthony
Top achievements
Rank 1
answered on 16 Aug 2015, 01:36 AM

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)...

 

0
Vladimir Iliev
Telerik team
answered on 18 Aug 2015, 11:28 AM
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!
 
0
Srinivas
Top achievements
Rank 1
answered on 06 Jan 2016, 09:36 PM

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
0
Vladimir Iliev
Telerik team
answered on 08 Jan 2016, 12:01 PM
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!
 
Tags
Grid
Asked by
Nervia Consultores S.L.
Top achievements
Rank 1
Answers by
Nervia Consultores S.L.
Top achievements
Rank 1
Vladimir Iliev
Telerik team
Greg
Top achievements
Rank 1
anthony
Top achievements
Rank 1
Srinivas
Top achievements
Rank 1
Share this question
or