﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - WebGrid Enterprise - How to hold and pass a value bet webgrid events across grid refresh</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-hold-and-pass-a-value-bet-webgrid-events-across-grid-refresh/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>How to hold and pass a value bet webgrid events across grid refresh</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-hold-and-pass-a-value-bet-webgrid-events-across-grid-refresh/</link><pubDate>Sun, 02 Oct 2011 06:18:19 GMT</pubDate><dc:creator>yudi</dc:creator><description>&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;Apologize for the delay in sending this.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;Please follow the step-by-step below in order to implement you required scenario.&lt;/span&gt;&lt;/p&gt;
&lt;ol&gt;&lt;li style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;Create grid, assign DataSource, DataMember and RetrieveStructure as shown in the CustomVirtualLoad.aspx tutorial file. The tutorial file is available at WebGrid Tutorial project inside the V3.5 folder.&lt;/li&gt;&lt;li style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;In the attached sample file, the value of VirtualPageSize property is set to “10”.&lt;/li&gt;&lt;li style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;Add an ASP.NET HiddenField control, HiddenField1, into the page. This control is used to store the total loaded rows of WebGrid. &lt;pre&gt;&amp;lt;asp:HiddenField ID="HiddenField1" runat="server" /&amp;gt;&lt;/pre&gt;&lt;/li&gt;&lt;li style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;Add OnBeforeRequest client-side event of WebGrid. This event specifies the client-side function to be invoked when a request action to server is about to be made. Within this event, the value of HiddenField1 control is set based on the value of the action parameter. &lt;pre&gt;function WebGrid1_OnBeforeRequest(controlId, action) {
    var WebGrid1 = ISGetObject(controlId);
    var hf = document.getElementById("HiddenField1");
            
    if (action == "More") {
        if (hf.value != "")
            hf.value = parseInt(hf.value) &amp;#43; 10;
        else
            hf.value = WebGrid1.TotalLoadedRows &amp;#43; 10;
    }
            
    return true;
}&lt;/pre&gt;&lt;/li&gt;&lt;li style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;Invoke the InitializePostBack server side event. &lt;pre&gt;protected void WebGrid1_InitializePostBack(object sender, PostbackEventArgs e)
{
    if (HiddenField1.Value != "")
    {
        WebGrid1.LayoutSettings.VirtualPageSize = int.Parse(HiddenField1.Value);
        WebGrid1.VirtualLoadArgs.RequestedRows = int.Parse(HiddenField1.Value);
    }

    if (e.Action == "More")
    {
        WebGrid1.RebindDataSource();
        ISNet.WebUI.FunctionParameter[] total = new ISNet.WebUI.FunctionParameter[1];
        total[0] = new ISNet.WebUI.FunctionParameter(WebGrid1.VirtualLoadArgs.TotalDataSourceRows.ToString(), "string");
        WebGrid1.ClientAction.InvokeScript("SetTotal", total);
    }

    else if (e.Action == "ColumnSort")
    {
        WebGrid1.RebindDataSource();
        ISNet.WebUI.FunctionParameter[] total = new ISNet.WebUI.FunctionParameter[1];
        total [0] = new ISNet.WebUI.FunctionParameter(WebGrid1.VirtualLoadArgs.TotalDataSourceRows.ToString(),"string");
        WebGrid1.ClientAction.InvokeScript("SetTotal",total);
    }
}&lt;/pre&gt;&lt;/li&gt;&lt;li style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;Attach a client-side event on OnAfterResponse event. The event is used to set the value of TotalLoadedRows property of WebGrid based on the value stored in HiddenField1 control. &lt;pre&gt;function WebGrid1_OnAfterResponseProcess(controlId, actionName, lastRequestObject, xmlResponseObject) {
    var WebGrid1 = ISGetObject(controlId);
    var hf = document.getElementById("HiddenField1");
    var table = WebGrid1.RootTable;

    WebGrid1.TotalLoadedRows = hf.value;

    return true;
}&lt;/pre&gt;&lt;/li&gt;&lt;li style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;Add SetTotal JavaScript function. This function is used to synchronize the loaded indicator shown in the status bar of WebGrid. &lt;pre&gt;function SetTotal(total) {
    var WebGrid1 = ISGetObject("WebGrid1");
    var hf = document.getElementById("HiddenField1");

    if (hf.value != "")
        WebGrid1.GetElement(WG40.STATUSBAR, WG40.HTMLROW).childNodes[3].innerText = "Loaded " &amp;#43; hf.value &amp;#43; " of " &amp;#43; total;
}&lt;/pre&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;A simple sample is enclosed as attachment. Please have the sample tested on your end and let us know whether this helps or not.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>How to hold and pass a value bet webgrid events across grid refresh</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-hold-and-pass-a-value-bet-webgrid-events-across-grid-refresh/</link><pubDate>Thu, 15 Sep 2011 05:50:31 GMT</pubDate><dc:creator>Skgrid@intersoftpt.com</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;I want to load the same no. of records, which are already loaded into the grid across grid refresh.&lt;/p&gt;
&lt;p&gt;Scenario:&lt;/p&gt;
&lt;p&gt;The default "&lt;span style="font-size: 13px"&gt;VirtualPageSize" is &lt;/span&gt;50 records, first time 50 records will be loaded bydefault, then as user click on "Load More Date" from webgrid taskbar, the no. of sets of 50 records will be added to the grid, if available.&lt;/p&gt;
&lt;p&gt;Suppose I click 3 times on "Load More Data" them 3 sets of 50 records will be loaded to grid apart from the default 50 records, that is total 200 records are loaded.&lt;/p&gt;
&lt;p&gt;Now if I select 110th record and perform some operation, the do the grid refresh, it should retain 200 records and it should retain the item selection.&lt;/p&gt;
&lt;p&gt;To achieve this I want to store &lt;span style="font-size: 13px"&gt;WebGrid1.VirtualLoadArgs.RequestedRows in &lt;span style="font-size: 13px"&gt;WebGrid1_InitializeDataSource event&lt;/span&gt;&amp;nbsp;when "Load More Data"&amp;nbsp;icon is clicked from the grid taskbar, so next time when grid is refreshed, the same value I want to set the same value to &lt;span style="font-size: 13px"&gt;e.Layout.VirtualPageSize&lt;/span&gt;&amp;nbsp;in &lt;span style="font-size: 13px"&gt;WebGrid1_InitializeLayout event.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 13px"&gt;&lt;span style="font-size: 13px"&gt;I have tried using page local variable, hiddenfield, context, cookies etc, but nothing seems to working.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 13px"&gt;&lt;span style="font-size: 13px"&gt;I am not able to hold the value and pass it across the &lt;span style="font-size: 13px"&gt;WebGrid1_InitializeDataSource&amp;nbsp;&lt;/span&gt;and &lt;span style="font-size: 13px"&gt;&lt;span style="font-size: 13px"&gt;WebGrid1_InitializeLayout events.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 13px"&gt;&lt;span style="font-size: 13px"&gt;Please suggest as soon as possible.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 13px"&gt;&lt;span style="font-size: 13px"&gt;&lt;/span&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 13px"&gt;&lt;span style="font-size: 13px"&gt;Thanks and Regards&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</description></item></channel></rss>