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

[Solved] Javascript function rebind causes whole page to reload

2 Answers 120 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.
Björn
Top achievements
Rank 1
Björn asked on 23 Feb 2012, 01:43 PM
Hello

I am setting up a grid within a smaller component.

The whole component is fetched through ajax and the grid is displayed correctly and the ajax updates for the server bindings for paging, sorting etc is working fine. However I have a textbox used to do a quicksearch in the grid and can't get the grid to rebind the data with the filter.

When the rebind function is called the whole page is posted back to itself instead of triggering a ajaxcall (the same thing happens for the ajaxMethod call). Any idea how we can force the grid to re-populate itself with ajax?

This is grid setup:
GridBuilder<T> factory = html.Telerik().Grid<T>();
 
factory.Name("QuickSearch");
factory.DataBinding(builder =>
                    builder.Ajax()
                    .Enabled(true)
                    .Select("AjaxGetObject", "Ajax")
                    .OperationMode(GridOperationMode.Server));
factory.Columns(grid.GetColumns());
factory.Sortable(builder => builder.Enabled(true));
factory.Pageable(builder =>
                builder.PageSize(grid.PageSize).Total(grid.TotalRecords).Enabled(true));
 
factory.EnableCustomBinding(true);           
        



Ajax controller header:
[GridAction(EnableCustomBinding = true)]
public ActionResult AjaxGetObject(GridCommand command, string searchExpression)

Javascript code for the search:
function Rebind(search) {
        var grid = $("#QuickSearch").data("tGrid");
        grid.rebind({ searchExpression: search });
    }

2 Answers, 1 is accepted

Sort by
0
Björn
Top achievements
Rank 1
answered on 23 Feb 2012, 01:50 PM
This was a really stupid mistake from my part. I solved the problem
0
Matt
Top achievements
Rank 1
answered on 19 Mar 2012, 04:01 AM
Please share your answer.
Tags
Grid
Asked by
Björn
Top achievements
Rank 1
Answers by
Björn
Top achievements
Rank 1
Matt
Top achievements
Rank 1
Share this question
or