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

[Solved] How does Server Binding work and accessing Command object

6 Answers 168 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.
Akzhol The Kyrgyz
Top achievements
Rank 1
Akzhol The Kyrgyz asked on 08 May 2010, 03:29 PM
How does server binding work? I need general overview of the process in order solve my problems and not to bother telerik support every time.

url?complicated-filtering-sorting-paging-paramters

When I click for example page 5:
1 - Telerik handles all url parameters before user defined ActionMethod is called and store it somewhere. (Is it so? If it is doing so, how can access command object?)
2 - Let the user defined Action Method to run and give data model (usually IQueryable)
3 - Use previously stored command data (filtering, sorting, page) to render actual HTML.

Is above process flow true?
I need this info to solve my problems. For instance one problem to solve is exporting to excel:

I'm implementing a generic export action method in BaseController [which is base to all my controllers], that has following pseudo code. [Every Controller implements getObjectList()]

public ActionResult Export(string[] columns, string[] titles, string fileName) 
    IQuerable data = getObjectList(); 
    Construct Excel Document Using Reflection and column names. 
    return Excel. 

The problem with this code is that it exports all the data, but I want it to export data after applying filter and orderby (no need for page and groupby).

So I want to add following line of code:
IEnumerable real_data = data.ToGridModel(page, data.count(), orderBy, "", filter); 

Where can access orderBy and filter? 

Thanks in advance.






















6 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 10 May 2010, 08:23 AM
Hi Akzhol The Kyrgyz,

I suggest you check the server binding and custom binding help topics. Additionally you can check the custom binding online example.

Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Akzhol The Kyrgyz
Top achievements
Rank 1
answered on 10 May 2010, 08:54 AM
Hi, Atanas
Thanks very much for your quick answer.

Yes I know that Custom Binding is probable solution to this problem, but not the effective one. Because If I could access "command"using server binding and from any controller then I would solve my problem in baseController. However if I use Custom Binding I've to modify around 30-50 grids/controllers which is error prone and will result in other design issues. Also I've my own ToolBox which makes some assumptions, so changing to Custom Binding will cause some problems there too.

So how about my assumption about how telerik-grid works in server binding? Is it correct?
I need general process flow to speed up my custom solution to this problem.

Thanks in advance.





0
Atanas Korchev
Telerik team
answered on 10 May 2010, 08:59 AM
Hi Akzhol The Kyrgyz,

The grid command object will be accessible if you decorate your action method with the [GridAction] attribute. However there is a known issue with proper population of the GridCommand and server binding - you can find a hotfix build attached here.

Generally speaking the grid is using the query string arguments to process the provided data (page, sort etc) unless custom binding is enabled.

Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Akzhol The Kyrgyz
Top achievements
Rank 1
answered on 10 May 2010, 09:35 AM
[quote]
Generally speaking the grid is using the query string arguments to process the provided data (page, sort etc) unless custom binding is enabled. 
[/quote]

This what I want: I want to parse command from query string arguments. Since this is already done in Telerik Grid, I want to use its functionality. Assume any point in any controller, I still have QueryString in my Request, so I can use it. 
In telerik-grid it can be done in this way

                GridActionBindingContext context = new GridActionBindingContext(EnableCustomBinding, filterContext.Controller, model.Data, model.Total); 
                GridDataProcessor dataProcessor = new GridDataProcessor(context); 
        IQuerably very_wanted_data = dataProcessor.ProcessedDataSource 
 

But what can supply instead of "filterContext.Controller",  I'm having problem at this step.?


The above link provides a binary, but I need source code, to apply some other fixes that I get through forums here.
 Moreover  I want to contribute something to this community and implement generic export to excel & print,  that's not dependent on some assumptions. Solving above would be enable also doing so.

Thanks.


0
Atanas Korchev
Telerik team
answered on 10 May 2010, 09:45 AM
Hello Akzhol The Kyrgyz,

We have decided not to attach the source code of such internal hotfixes. What are the fixes you need to apply manually? We are incorporating all fixes in our code so this build should have all reported and officially recognized bugs fixed.

The GridCommand has a Parse method built in. You just need to pass the required values (extract them from query string).

We have published a knowledge base article showing how to perform excel export. You can download the code and check it out.

Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Akzhol The Kyrgyz
Top achievements
Rank 1
answered on 15 May 2010, 04:33 PM
Hi, Atanas

Thank you very much for your answers. Actually I investigated a lot before posting here, so I've investigated the link you have sent several times before. 
Thanks to your tips I found an answer to my question:
It seems that I couldn't explain my problem well, otherwise the answer to my question:
"Where can access orderBy and filter? " would be "Request["orderBy"]" and "Request["filter"] "

Thanks again. I'll post my solution to a blog soon.
Tags
Grid
Asked by
Akzhol The Kyrgyz
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Akzhol The Kyrgyz
Top achievements
Rank 1
Share this question
or