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

[Solved] dynamically change page number for Grid

0 Answers 160 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.
Aiyaz
Top achievements
Rank 1
Aiyaz asked on 12 Jul 2010, 06:31 AM
Hi,

I have a grid using ajaxbinding with some parameters.  Im trying to change the change the page number before the binding occurs but it doesnt seem to work.  How do I change grid params e.g page,size,orderBy,groupBy before the binding occurs.  Basically I want the grid to display data on a specific page.  Ive tried changing the following parameters on the grid object. "currentPage", "page".

$(function () {
           $("#RunQuery").click(function () {
               var fromDate = new Date($("#FromDate").data("tDatePicker").value());
               var toDate = new Date($("#ToDate").data("tDatePicker").value());
               fromDate = fromDate.getDate() + "/" + (fromDate.getMonth() + 1) + "/" + fromDate.getFullYear();
               toDate = toDate.getDate() + "/" + (toDate.getMonth() + 1) + "/" + toDate.getFullYear();
               var taskMessagesGrid = $("#TaskMessages").data('tGrid');
               taskMessagesGrid.rebind({ fromDate: fromDate, toDate: toDate,page: 5 });
           });
       });
Telerik grid
<%=Html.Telerik().Grid<
TaskMessage>()
            .Name("TaskMessages")
            .ClientEvents(
            c => c
                .OnRowDataBound("onRowDataBound")
                .OnRowSelected("rowSelected")
                .OnDataBound("onDataBound")
                 
                 
            )
            .DataBinding (dataBinding => dataBinding.Ajax().Select("TaskMessagsByEmployee", "Task", new {fromDate = DateTime.Now.AddYears(-2).ToString(), toDate = DateTime.Now.ToString()})) 
            .Groupable(g => g
                    .Groups(c => c.Add(b => b.MessageCreatedDateTimeShort))
                    .Groups(h => h.Add(m => m.MessageIDWithSubject))
                    )
            .Pageable(p => p.PageSize(10).Style(GridPagerStyles.NextPreviousAndNumeric))
            .Selectable()
            .Sortable(s => s.OrderBy(f => f.Add(o => o.MessageCreatedDateTime)))
            .Columns(columns =>
            {
                columns.Bound(o => o.TaskID).Sortable(false);
                columns.Bound(o => o.CreatedDateTime).Title("Date").Format("{0:dd/MM/yyyy}").Sortable(false);
                columns.Bound(o => o.ProblemStatementShort)
                    .Sortable(false)
                    .Title("Subject")
                    .ClientTemplate("<label alt='<#=ProblemStatement#>'><#=ProblemStatementShort#></label>");
                columns.Bound(o => o.RaisedByEmployeeName).Title("Raised By").Sortable(false);
                columns.Bound(o => o.TaskStatusDescription).Title("Status").Sortable(false);
                columns.Bound(o => o.MessageCreatedDateTimeShort)
                    .Title("<label class='firstGroupHeader'>asda</label>")
                    .Format("{0:dddd dd MMM yyyy}")
                    .Hidden(true);
                columns.Bound(o => o.MessageIDWithSubject)
                    .Visible(false)
                    .Title(">");
            })
        %>
Tags
Grid
Asked by
Aiyaz
Top achievements
Rank 1
Share this question
or