How to maintain page index after postback.

  1. #1

    How to maintain page index after postback.

    Hi,
    I am using Grid Panel to show data. In which on clicking for Edit Button, I am doing postback as follows -
    
    <asp:Button ID="btnEdit" runat="server" OnClick="btnEdit_Click" Style="display: none" />
    
     <Listeners>
             <Command Handler="javascript:showPanel(record.data.ID);" />
    </Listeners>
    
    <script type="text/javascript">
    
    function showPanel(value) {
                __doPostBack('btnEdit', value);
            }
        </script>
    in code behind -

    protected void btnEdit_Click(object sender, EventArgs e)
        {
    // some code to load details
    }
    But after postback I am loosing page Index as I am binding store again.
  2. #2
    Please reply someone, I am kind of stuck with this.

    Quote Originally Posted by itskvini View Post
    Hi,
    I am using Grid Panel to show data. In which on clicking for Edit Button, I am doing postback as follows -
    
    <asp:Button ID="btnEdit" runat="server" OnClick="btnEdit_Click" Style="display: none" />
    
     <Listeners>
             <Command Handler="javascript:showPanel(record.data.ID);" />
    </Listeners>
    
    <script type="text/javascript">
    
    function showPanel(value) {
                __doPostBack('btnEdit', value);
            }
        </script>
    in code behind -

    protected void btnEdit_Click(object sender, EventArgs e)
        {
    // some code to load details
    }
    But after postback I am loosing page Index as I am binding store again.
  3. #3
    Hi,

    Maybe the following forum post can help, see

    http://forums.ext.net/showthread.php...om-code-behind

    Any particular reason why you must do a full page post-back? Why not just make an Ajax (DirectEvent/DirectMethod) call back to the server?
    Geoffrey McGill
    Founder
  4. #4
    Thanks,

    It did help me. But surprisingly I haven't done anything to maintain PageIndex, I have user your solution to maintain Page Size after postback.

    Here is snippet from my code

    In .aspx file
    
    <BottomBar>
    	<ext:PagingToolbar ID="PagingToolbar1" runat="server" PageSize="10" AutoWidth="true"
    		EnableViewState="true">
    		<Items>
    			<ext:Label ID="Label1" runat="server" Text="Page size:" />
    			<ext:ToolbarSpacer ID="ToolbarSpacer1" runat="server" Width="10" />
    			<ext:ComboBox ID="ComboBox1" runat="server" Width="80">
    				<Items>
    					<ext:ListItem Text="1" />
    					<ext:ListItem Text="2" />
    					<ext:ListItem Text="10" />
    					<ext:ListItem Text="20" />
    				</Items>
    				<SelectedItem Value="10" />
    				<Listeners>
    					<Select Handler="#{PagingToolbar1}.pageSize = parseInt(this.getValue()); #{ehfPageSize}.setValue(parseInt(this.getValue()));#{PagingToolbar1}.doLoad();" />
    				</Listeners>
    			</ext:ComboBox>
    		</Items>
    		<Listeners>
    		</Listeners>
    	</ext:PagingToolbar>
    </BottomBar>
    <Listeners>
    	<Command Handler="#{CommandInfo}.setValue(record.data.EquityID); #{CommandTrigger}.fireEvent('click');#{ehfPageSize}.setValue(#{PagingToolbar1}.pageSize);" />
    </Listeners>
    </ext:GridPanel>
    <ext:Hidden ID="CommandInfo" runat="server" />
    <ext:Hidden ID="ehfPageSize" runat="server" />
    <ext:Button ID="CommandTrigger" runat="server" Hidden="true" AutoPostBack="true"
    OnClick="CommandExecuted">
    </ext:Button>
    In code behind

    protected void CommandExecuted(object sender, EventArgs e)
        {
            PagingToolbar1.SetPageSize(Convert.ToInt32(ehfPageSize.Value));
            Store1.Sort(hfSortField.Value.ToString(), hfSortDirection.Value.ToString() == "ASC" ? Ext.Net.SortDirection.ASC : Ext.Net.SortDirection.DESC);
    
           // calling function to load details
    
        }
    Added listener for maintaining sort info in hidden filed like

    <Listeners>
          <SortChange Handler="#{hfSortField}.setValue(sortInfo.field); #{hfSortDirection}.setValue(sortInfo.direction);" />
    </Listeners>
    It's working fine but some how "OnRefreshData" event is getting called multiple times after full postback.
    Last edited by itskvini; Jul 06, 2012 at 4:55 AM.

Similar Threads

  1. [CLOSED] Cross-page Postback
    By alliedwallet.com in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 16, 2011, 1:19 PM
  2. Replies: 0
    Last Post: Jul 14, 2011, 11:08 AM
  3. Replies: 3
    Last Post: Dec 20, 2010, 6:32 AM
  4. [CLOSED] [1.0] Grid reload and maintain page index
    By edigital in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jun 23, 2010, 5:41 PM
  5. Store/Retrieve page index of a GridPanel
    By mrozik in forum 1.x Help
    Replies: 0
    Last Post: Jul 27, 2009, 4:41 AM

Tags for this Thread

Posting Permissions