This is a migrated thread and some comments may be shown as answers.
radgrid live update e.NewPageIndex gets -1
3 Answers 48 Views
This is a migrated thread and some comments may be shown as answers.
Vaibhav
Top achievements
Rank 1
Vaibhav asked on 03 Nov 2008, 09:13 AM
Hi,

I am doing live data update on radgrid with paging.
When webservice is called and result set is changed I get e.NewPageIndex = -1.

This halts live update process.

Please give your suggestions.

Thanks,
Vaibhav

3 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 05 Nov 2008, 04:14 PM
Hello Vaibhav,

Can you show us your RadGrid markup and how you bind RadGrid on the client? Additionally, you can visit the following demo - Live data from web service which demonstrates the RadGrid client-side binding capabilities.

Kind regards,
Nikolay
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Vaibhav
Top achievements
Rank 1
answered on 06 Nov 2008, 01:42 PM
Hi Nikolay,

Please see below script and grid markup

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

        <script type="text/javascript" language="javascript">
        
        function pageLoad()
        {
            if(document.getElementById('<%=hidGridFilterInit.ClientID %>').value == 0)
            {
                $find('<%=dgrdBroadcasts.ClientID %>').get_masterTableView().hideFilterItem();
            }
            else
            {
                $find('<%=dgrdBroadcasts.ClientID %>').get_masterTableView().showFilterItem();
            }
            
            setInterval("refreshGrid()", 20000);
        }
        
        function refreshGrid()
        {
            SmartBroadcast.GetJobs.cBindGrid(updateGrid);
    
        }
    
        function updateGrid(result)
        {
            var tableView = $find("<%= dgrdBroadcasts.ClientID %>").get_masterTableView();
            var virtualCount = tableView.getCellByColumnUniqueName(tableView.get_dataItems()[0],"total_rows").innerHTML;
            tableView.set_virtualItemCount(10);
            tableView.set_dataSource(result);
            tableView.dataBind();
        }
        
        function dgrdBroadcasts_RowDataBound(sender, args)
        {
                              
            var dt = new Date();
            
            
            if (args.get_dataItem()["Job_Date_ASAP"] == 'Y')
            {
                dt = args.get_dataItem()["Submit_Date"];
                if (args.get_dataItem()["Status"] == 'DONE' || args.get_dataItem()["Status"] == 'SUBMITTED')
                {
                    args.get_item().get_cell("Job_Date").innerHTML = formatDate(dt);
                }
                else
                {
                    args.get_item().get_cell("Job_Date").innerHTML = 'ASAP';
                }
            }
            else
            {
                dt = args.get_dataItem()["Job_Date"];
                args.get_item().get_cell("Job_Date").innerHTML = formatDate(dt);
            }
        }
        
        function formatDate(dt)
        {
            dt = (dt.getMonth()+ 1) + '/' + dt.getDate() + '/' + dt.getFullYear() + ' ' + (dt.getHours() < 12 ? dt.getHours() : dt.getHours()%12) + ':' + dt.getMinutes() + ' ' + (dt.getHours() < 12 ? 'AM' : 'PM');
           
            return dt;
        }
        </script>

    </telerik:RadCodeBlock>

    <telerik:RadGrid ID="dgrdBroadcasts" runat="server" AllowPaging="true" AllowSorting="true"
                            AutoGenerateColumns="false" PagerStyle-AlwaysVisible="true" PagerStyle-Mode="NextPrevNumericAndAdvanced"
                            Skin="Office2007" EnableEmbeddedSkins="false" PagerStyle-ShowPagerText="true"
                            AllowCustomPaging="true" PagerStyle-PagerTextFormat="Change page: {4} &nbsp;|&nbsp;Displaying page {0} of {1}, items {2} to {3} of {5}."
                            >
                            <HeaderStyle HorizontalAlign="left" VerticalAlign="Middle" Font-Bold="true" Font-Names="verdana"
                                Font-Size="8.5pt" Height="25px" ForeColor="Black" CssClass="bgtop"></HeaderStyle>
                            <MasterTableView NoMasterRecordsText="No records found." RowIndicatorColumn-Display="false"
                                CellPadding="1" AllowFilteringByColumn="true" DataKeyNames="Job_Type,Status" >
                                <Columns>
                                    <telerik:GridTemplateColumn HeaderText="Edit" Reorderable="False" SortExpression="Job_id"
                                        Resizable="False" AllowFiltering="False" UniqueName="TemplateColumn" ItemStyle-Font-Names="Verdana"
                                        ItemStyle-VerticalAlign="NotSet">
                                        <ItemStyle CssClass="lnkcolor" />
                                        <ItemTemplate>
                                            <asp:LinkButton ID="lnkBroadcastID" ToolTip="" runat="server" CommandName="Summary">LinkButton</asp:LinkButton>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridBoundColumn DataField="Job_Type" Reorderable="False" Resizable="False"
                                        SortExpression="Job_type" HeaderText="Type" UniqueName="Job_Type" ItemStyle-Font-Names="Verdana"
                                        AllowFiltering="false">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridTemplateColumn DataField="Description" AllowFiltering="true" HeaderText="Description"
                                        Reorderable="False" UniqueName="description" ItemStyle-Font-Names="Verdana" SortExpression="Description"
                                        Resizable="False">
                                        <ItemTemplate>
                                            <asp:Label ID="lblDescription" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.description") %>'>
                                            </asp:Label>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridBoundColumn DataField="Account_Code" Reorderable="False" SortExpression="account_code"
                                        ReadOnly="True" HeaderText="Account" ItemStyle-Font-Names="Verdana" Resizable="False">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Sender_Code" Reorderable="false" SortExpression="Sender_Code"
                                        HeaderText="Sender" UniqueName="Sender_Code" ItemStyle-Font-Names="Verdana" Resizable="False">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="em_broadcast_id" Reorderable="False" SortExpression="em_broadcast_id"
                                        HeaderText="DeliveryID" UniqueName="em_broadcast_id" ItemStyle-Font-Names="Verdana"
                                        Resizable="False">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Job_Date" Reorderable="False" SortExpression="Job_date"
                                        HeaderText="Delivery" DataFormatString="{0:d} {0:hh:mm tt}" UniqueName="Job_date"
                                        AllowFiltering="True" ItemStyle-Font-Names="Verdana" Resizable="False">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Created_By_Name" Reorderable="False" HeaderText="Created By"
                                        UniqueName="Created_By_Name" ItemStyle-Font-Names="Verdana" Resizable="False">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridTemplateColumn DataField="status" HeaderText="Status" Resizable="False"
                                        SortExpression="status" Reorderable="False" UniqueName="Status" ItemStyle-Font-Names="Verdana"
                                        AllowFiltering="true">
                                        <ItemTemplate>
                                            <asp:Label ID="lblStatus" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.status") %>'>
                                            </asp:Label>
                                            <asp:HyperLink ID="lnkStatus" Visible="False" runat="server" Font-Bold="true" ForeColor="red"
                                                Text='<%# DataBinder.Eval(Container, "DataItem.status") %>'>
                                            </asp:HyperLink>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridBoundColumn DataField="total_rows" Display="false"
                                        UniqueName="total_rows" >
                                    </telerik:GridBoundColumn>
                                    <telerik:GridTemplateColumn Visible="false" Reorderable="False" Resizable="False"
                                        UniqueName="Action" AllowFiltering="False" ItemStyle-Font-Names="Verdana">
                                        <ItemTemplate>
                                            <asp:Button ID="btnEdit" Visible="false" runat="server" CommandName="Edit" Text="Edit"
                                                Height="20px" Width="30px" CssClass="eB_buttons"></asp:Button>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                </Columns>
                            </MasterTableView>
                            <ClientSettings ReorderColumnsOnClient="False" AllowDragToGroup="False" AllowColumnsReorder="False">
                                <Resizing AllowRowResize="false" AllowColumnResize="false"></Resizing>
                                <ClientEvents OnRowDataBound="dgrdBroadcasts_RowDataBound" />
                            </ClientSettings>
                            <FilterItemStyle BackColor="" BorderColor="Black" Width="20px" Wrap="True" />
                        </telerik:RadGrid>
============================

Protected Sub dgrdBroadcasts_PageIndexChanged(ByVal source As System.Object, ByVal e As Telerik.Web.UI.GridPageChangedEventArgs) Handles dgrdBroadcasts.PageIndexChanged
        dgrdBroadcasts.CurrentPageIndex = e.NewPageIndex  ' e.NewPageIndex GETS -1
        BindGrid()
    End Sub

Protected Overrides Sub RaisePostBackEvent(ByVal source As IPostBackEventHandler, ByVal eventArgument As String)
        MyBase.RaisePostBackEvent(source, eventArgument)  ' HERE COMES THE ERROR
        If TypeOf source Is RadGrid Then
            Select Case eventArgument
                Case "ResetAndRebind"
                    'dgrdBroadcasts.Rebind()
                    BindGrid("created_date DESC")

            End Select
        End If
    End Sub





============================

Waiting for reply,

Thanks,
Vaibhav

0
Nikolay Rusev
Telerik team
answered on 10 Nov 2008, 04:00 PM
Hello Vaibhav,

Unfortunately I am not able to determine what is causing the issue from the information provided so far.
If you could open a formal support ticket and send us small runnable application which replicates the issue. Thus we'll be able to debug it locally and help you more on this.

Kind regards,
Nikolay
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Vaibhav
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Vaibhav
Top achievements
Rank 1
Share this question
or