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

[Solved] Problem when paging with parameter (ajax binding)

1 Answer 75 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.
Darwin Tate
Top achievements
Rank 1
Darwin Tate asked on 31 Jul 2011, 04:59 PM
I have one textbox, one button, and one grid. When I type something into textbox and click button, the grid show result information. I'm using ajax binding, and allow paging.
When i use firebug to find request url, it show like that: value=abc&page=1&size=10&orderBy=&groupBy=&filter=&aggregates=
But when click page 2 (at the bottom of grid), grid is shows nothing, and url is: page=2&size=10&orderBy=&groupBy=&filter=&aggregates=
Why it can't passing parameter "value=abc" to another page???
Any one can hepl me!
Thank for reading!

1 Answer, 1 is accepted

Sort by
0
Darwin Tate
Top achievements
Rank 1
answered on 31 Jul 2011, 06:57 PM
Here is my javascript code
<script type="text/javascript">    
    var first = true;
     function onDataBinding(e) {
         if (first) {
             e.preventDefault();
             first = false;
         }
     }
  
     function rebindGrid() {
         var value= $('#txtSearch').val();
         var grid = $("#Grid").data("tGrid");
         grid.rebind({ value:txtSearch});
       }
</script>

And here is my View:
........
@Html.TextBox("txtSearch")
<input type="button" id="btnSearch" onclick="rebindGrid()" value="Search" />
 
......Grid........
.DataBinding(databinding =>
                databinding.Ajax()
                .Select("_Index", "Customer")
.........
.ClientEvents(events => events.OnDataBinding("onDataBinding"))

And controller
[GridAction]
public ActionResult _Index(string value)
{
    return View(new GridModel { Data = repository.GetCustomersByName(value) });
}

I don't know why???
Tags
Grid
Asked by
Darwin Tate
Top achievements
Rank 1
Answers by
Darwin Tate
Top achievements
Rank 1
Share this question
or