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

[Solved] Is it possible to rebind the ajax url?

4 Answers 106 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.
Patrik
Top achievements
Rank 1
Patrik asked on 28 Sep 2011, 10:49 AM
We have a small grid that looks like this:

@(Html.Telerik()
    .Grid(Model.Model.CommunityHelpdeskThreads)
    .Name("CommunityHelpdeskThreadGrid")
            .Columns(columns =>
                         {
                             columns.Bound(dlm => dlm.Title)
                                .ClientTemplate("<#=Title#>");
                             columns.Bound(dlm => dlm.PostCount)
                                 .Width(100);
                         }
            )           
    .EnableCustomBinding(true)
    .Pageable(paging => paging.PageSize(10))
    .DataKeys(dk => dk.Add(key => key.ThreadId)))

However we can't specify the databinding at this point since the parameters are still unknown.
So we tried to add a javascript to rebind the grid but it's not working:

function CommunityHelpdeskThreadGrid_ApplyDataBinding() {
    try {
 
 
        var grid = getGrid('CommunityHelpdeskThreadGrid');
        if (grid == null) return;
 
 
        grid.ajax.selectUrl = '/Community/Helpdesk/_GetThreadsForSearch/' + parameter;
        grid.rebind();
         
    } catch (e) {
        alert("Error occured" + e);
    }
 
}

No call is being made to the server.

Any ideas?

4 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 29 Sep 2011, 10:01 AM
Hello Patrik,

In order to use rebind method, grid component should be set to use ajax binding instead of server binding used in the snippet you have pasted.

Regards,
Rosen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Patrik
Top achievements
Rank 1
answered on 29 Sep 2011, 11:25 AM
The problem is that we want to avoid that it databinds before the url has been properly set. This occurs when they type something in the search field.
So i don't want the initial bind and i also don't want the users to be able to press refresh.
0
Accepted
Rosen
Telerik team
answered on 29 Sep 2011, 01:09 PM
Hi Patrik,

You may use DataBinding event to prevent the grid to be automatically populated on initial load when ajax binding is use. 

var initialLoad = true;
 
function dataBound(e) {
     if (initialLoad) {
          e.preventDefault();
          initialLoad = false;
     }
}

All the best,
Rosen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Patrik
Top achievements
Rank 1
answered on 29 Sep 2011, 02:31 PM
Ok, thanks
Tags
Grid
Asked by
Patrik
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Patrik
Top achievements
Rank 1
Share this question
or