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

[Solved] Operation Client Mode not binding data

4 Answers 197 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
James
Top achievements
Rank 1
James asked on 26 Aug 2011, 04:06 PM
Hi,

I've created a Grid will works and performs as expected when loaded using Ajax Server Operation Mode, however when changing the mode to Client, the data that is requested from the server is not displayed.

The Ajax call is made and the data is returned from the server just like with Server Operation Mode, there are no JavaScript errors highlight by Firebug etc. I was wondering if other's have experienced this. I've been unable to determine why this might happen, I tried to fault check, including removing all other scripts that run on the page, minimal grid options etc.

The data is displayed at time of render is the data is supplied to the grid initially, however firing client events from then on results in 'no records found'.

Currently using Q2 release with Jquery 1.5.1 (contained within the release).

If anybody's got any ideas it would be most appreciated.

Thanks,


UPDATE - I have found that the data that is loaded via ajax can be access through

var data =  $('#NAME').data('tGrid').dataSource._data

I can then force the grid to repopulate using $('#NAME').data('tGrid')._populate(data)

However this needs to be called on every databind. This leads me to think that there is a data binding / repainting problem, or that _populate is not being called for some reason, or that the change is data (i.e. the ajax request is completed with the data returned) goes unnoticed (I think this may be the key) 

4 Answers, 1 is accepted

Sort by
0
James
Top achievements
Rank 1
answered on 27 Aug 2011, 07:56 PM
So I manage to find the issue - after digging around I discovered that the data change was noticed however dataSource.view() (in t.grid.min.cs) was returning empty.

This view is the result of the data being processed - within t.common.cs. Essentially the data is processed for the filters, sorting etc...

The issue lay with the paging filter. I haven't yet looking into why this is, but after the data is passed to the paging filter (with only a couple of results in this case) the page removes (or rather skips) the first page, therefore if you have under 1 complete page's worth, the data is removed from the view set.
0
James
Top achievements
Rank 1
answered on 27 Aug 2011, 08:05 PM
The answer is to have Pageable() on in your view definition.

It took be the better part of a day but as identified above, this filter is applied to the data when it's processed after being requested

if (page !== undefined && pageSize !== undefined) {
            query = query.skip((page - 1) * pageSize).take(pageSize);
        }

(This is in telerik.common.cs  )

By default it would appear that page  = 1 and pageSize = 0 therefore both are defined

So it reads : query.skip((page - 1)* 0).take(0);

I'm not sure if this is by design or maybe I've messed up somewhere, but it seems that if you use client operation mode on the grid in Q2 2011 release, you MUST use paging. I couldn't find any help info around so if might be worth mentioning in the docs (or changing default pageSize)

0
Nick
Top achievements
Rank 1
answered on 22 Sep 2011, 11:34 PM
Thanks for posting this. I doubt it is intended that the only difference between displaying and not displaying your data is ".Pageable()".
0
Phil
Top achievements
Rank 1
answered on 01 Jun 2012, 11:08 AM
Hi,

I too found that when the grid is in client operation mode then the ajaxRequest method does not work.
I also discovered a quirk that if the grid is empty then (in client operation mode) it will do an ajax request.
I use this quirk to my advantage to force a grid reload in client operation mode within a function.

// Get a reference to the grid 

var grid = $("#MyGrid").data("tGrid");

// In client operation mode the grid's ajaxRequest only works if data is empty so

// first empty data

grid.dataSource._data = [];

// then reload

grid.ajaxRequest();

 

 

Hope this helps someone.

 


Tags
Grid
Asked by
James
Top achievements
Rank 1
Answers by
James
Top achievements
Rank 1
Nick
Top achievements
Rank 1
Phil
Top achievements
Rank 1
Share this question
or