﻿<?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 - Export the ability to stop InitializePostBack Action..</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Export-the-ability-to-stop-InitializePostBack-Action/</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>Export the ability to stop InitializePostBack Action..</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Export-the-ability-to-stop-InitializePostBack-Action/</link><pubDate>Tue, 03 Aug 2010 23:13:07 GMT</pubDate><dc:creator>Glayaar</dc:creator><description>&lt;p&gt;If you wish to retrieve the total row from filtered grid, you will need to get the count from the defaultview not the datatable. Here is the new snippet:&lt;/p&gt;&lt;pre&gt;protected void WebGrid1_PrepareDataBinding(object sender, DataSourceEventArgs e)&lt;br /&gt;{&lt;br /&gt;    rowTotal.Value = ((DataTable)WebGrid1.DataSource).DefaultView.Count.ToString();&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;You will also need to update the hidden value after every filter using the InitialisePostback server side event handler:&lt;/p&gt;&lt;pre&gt;protected void WebGrid1_InitializePostBack(object sender, PostbackEventArgs e)&lt;br /&gt;{&lt;br /&gt;    if (e.Action == PostBackAction.ColumnFilter)&lt;br /&gt;    {&lt;br /&gt;        rowTotal.Value = ((DataTable)WebGrid1.DataSource).DefaultView.Count.ToString();&lt;br /&gt;        WebGrid1.ClientAction.RenderControl(rowTotal);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Export the ability to stop InitializePostBack Action..</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Export-the-ability-to-stop-InitializePostBack-Action/</link><pubDate>Mon, 02 Aug 2010 16:28:12 GMT</pubDate><dc:creator>tlusby</dc:creator><description>&lt;p&gt;Yes and No.&lt;/p&gt;
&lt;p&gt;This works if you don't have filtering turned on; however, we give the user the ability to filter their data.  So, what is happening now is.  say the max is 6000 records.  I have returned data of 100,000 and then they filter column 1 and the total count is now 2000.  The rowcount is still showing 100,000 NOT the 2000 from the filter.  I have an aggregate count on column 1 if this helps.  Is there a way to retreive aggregate count value client side?&lt;/p&gt;</description></item><item><title>Export the ability to stop InitializePostBack Action..</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Export-the-ability-to-stop-InitializePostBack-Action/</link><pubDate>Thu, 29 Jul 2010 17:31:04 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;There is no way to abort export event from server side, so for your requirement we’ll need to cancel the export from client side.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;Since the grid uses paging, then GetRowsCount() method will returns the value PagingSize property instead of exact total rows retrieved by WebGrid. The total rows retrieved by WebGrid can be obtained by using hidden field. Please add following tag into your page.&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: #a31515; font-size: 9pt"&gt;input&lt;/span&gt; &lt;span style="font-family: 'courier new'; color: red; font-size: 9pt"&gt;type&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;="hidden"&lt;/span&gt; &lt;span style="font-family: 'courier new'; color: red; font-size: 9pt"&gt;id&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;="rowTotal"&lt;/span&gt; &lt;span style="font-family: 'courier new'; color: red; font-size: 9pt"&gt;name&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;="rowTotal"&lt;/span&gt; &lt;span style="font-family: 'courier new'; color: red; font-size: 9pt"&gt;runat&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;="server"&lt;/span&gt; &lt;span style="font-family: 'courier new'; color: red; font-size: 9pt"&gt;value&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;="0" /&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;The value of the rowTotal input object will be set during PrepareDataBinding server side event of WebGrid.&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;protected void&lt;/span&gt; WebGrid1_PrepareDataBinding(&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;object&lt;/span&gt; sender, ISNet.WebUI.WebGrid.&lt;span style="font-family: 'courier new'; color: #2b91af; font-size: 9pt"&gt;DataSourceEventArgs&lt;/span&gt; e)
{
    rowTotal.Value = ((&lt;span style="font-family: 'courier new'; color: #2b91af; font-size: 9pt"&gt;DataTable&lt;/span&gt;)WebGrid1.DataSource).Rows.Count.ToString();
}&lt;/pre&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;Next, modify the OnBeforeRequest function so it becomes as follow.&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;function&lt;/span&gt; WebGrid1_OnBeforeRequest(controlId, action) {
    &lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;var&lt;/span&gt; WebGrid1 = ISGetObject(controlId);
    &lt;span style="font-family: 'courier new'; font-size: 9pt"&gt;var&lt;/span&gt; rowsCount = document.getElementById(&lt;span style="font-family: 'courier new'; color: #a31515; font-size: 9pt"&gt;"rowTotal"&lt;/span&gt;).value;
    &lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;var&lt;/span&gt; maxExportRow = 50;

    &lt;span style="font-family: 'courier new'; color: green; font-size: 9pt"&gt;//check if request is made from Export action or not&lt;/span&gt;
    &lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;if&lt;/span&gt; (action == &lt;span style="font-family: 'courier new'; color: #a31515; font-size: 9pt"&gt;"Export"&lt;/span&gt;) {

        &lt;span style="font-family: 'courier new'; color: green; font-size: 9pt"&gt;//cancel export if exported rows amount is greater than maxExportRow&lt;/span&gt;
        &lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;if&lt;/span&gt; (parseInt(rowsCount) &amp;lt;= maxExportRow)
            &lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;return true&lt;/span&gt;;
        &lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;else&lt;/span&gt; {
            alert(&lt;span style="font-family: 'courier new'; color: #a31515; font-size: 9pt"&gt;"Exported rows are greater than 50 rows."&lt;/span&gt;);
            &lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;return false&lt;/span&gt;;
        }
    }
}&lt;/pre&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;This should do the trick. Please let us know whether this helps or not.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Export the ability to stop InitializePostBack Action..</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Export-the-ability-to-stop-InitializePostBack-Action/</link><pubDate>Mon, 26 Jul 2010 16:18:13 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;I need more time to discuss this with WebGrid development team.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt;"&gt;I’ll get back to you with the result of the discussion.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Export the ability to stop InitializePostBack Action..</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Export-the-ability-to-stop-InitializePostBack-Action/</link><pubDate>Fri, 23 Jul 2010 11:07:14 GMT</pubDate><dc:creator>tlusby</dc:creator><description>&lt;p&gt;Yudi,&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;I saw onBeforeRequest function the problem is we have Paging implemented and we have PagingSize=500 and PagingExportMode="ExportAllData" so they have the ability to export all data.  The only way to get all rows would be in the code behind, so that's why I said InitializePostback.&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Export the ability to stop InitializePostBack Action..</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Export-the-ability-to-stop-InitializePostBack-Action/</link><pubDate>Fri, 23 Jul 2010 00:23:56 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;The solution for your required scenario, to cancel export if the record count is beyond allowed amount of exported records, can be achieved by using OnBeforeRequest client side event of WebGrid.&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: #a31515; font-size: 9pt"&gt;script&lt;/span&gt; &lt;span style="font-family: 'courier new'; color: red; font-size: 9pt"&gt;type&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;="text/javascript"&amp;gt;&lt;/span&gt;
    &lt;span style="font-family: 'courier new'; color: green; font-size: 9pt"&gt;&amp;lt;!--&lt;/span&gt;
    &lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;function&lt;/span&gt; WebGrid1_OnBeforeRequest(controlId, action) {

    }
    &lt;span style="font-family: 'courier new'; color: green; font-size: 9pt"&gt;--&amp;gt;&lt;/span&gt;
&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: #a31515; font-size: 9pt"&gt;script&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;&amp;gt;&lt;/span&gt;

...

&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: #a31515; font-size: 9pt"&gt;ISWebGrid&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;:&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: #a31515; font-size: 9pt"&gt;WebGrid&lt;/span&gt; &lt;span style="font-family: 'courier new'; color: red; font-size: 9pt"&gt;ID&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;="WebGrid1"&lt;/span&gt; &lt;span style="font-family: 'courier new'; color: red; font-size: 9pt"&gt;runat&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;="server"&lt;/span&gt; &lt;span style="font-family: 'courier new'; color: red; font-size: 9pt"&gt;DataSourceID&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;="AccessDataSource1"&lt;/span&gt;
    &lt;span style="font-family: 'courier new'; color: red; font-size: 9pt"&gt;Height&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;="250px"&lt;/span&gt; &lt;span style="font-family: 'courier new'; color: red; font-size: 9pt"&gt;UseDefaultStyle&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;="True"&lt;/span&gt; &lt;span style="font-family: 'courier new'; color: red; font-size: 9pt"&gt;Width&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;="500px"&amp;gt;&lt;/span&gt;
    &lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: #a31515; font-size: 9pt"&gt;LayoutSettings&lt;/span&gt; &lt;span style="font-family: 'courier new'; color: red; font-size: 9pt"&gt;AllowExport&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;="Yes"&lt;/span&gt; &lt;span style="font-family: 'courier new'; color: red; font-size: 9pt"&gt;AllowFilter&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;="Yes"&amp;gt;&lt;/span&gt;
        &lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: #a31515; font-size: 9pt"&gt;ClientSideEvents&lt;/span&gt; &lt;span style="font-family: 'courier new'; color: red; font-size: 9pt"&gt;OnBeforeRequest&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;="WebGrid1_OnBeforeRequest" /&amp;gt;&lt;/span&gt;
    &lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: #a31515; font-size: 9pt"&gt;LayoutSettings&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;&amp;gt;&lt;/span&gt;
...
&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: #a31515; font-size: 9pt"&gt;ISWebGrid&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;:&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: #a31515; font-size: 9pt"&gt;WebGrid&lt;/span&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;First, we’ll need to determine from which actions the request was raised. If the request is raised from Export action, then check the record count and return false if the record is greater than, for example, 50 records.&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;&lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;function&lt;/span&gt; WebGrid1_OnBeforeRequest(controlId, action) {
    &lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;var&lt;/span&gt; WebGrid1 = ISGetObject(controlId);
    &lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;var&lt;/span&gt; rowsCount = WebGrid1.RootTable.GetRowsCount();

    &lt;span style="font-family: 'courier new'; color: green; font-size: 9pt"&gt;//check if request is raised from Export action or not&lt;/span&gt;
    &lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;if&lt;/span&gt; (action == &lt;span style="font-family: 'courier new'; color: #a31515; font-size: 9pt"&gt;"Export"&lt;/span&gt;) {

        &lt;span style="font-family: 'courier new'; color: green; font-size: 9pt"&gt;//cancel export if exported rows amount is greater than 50 rows&lt;/span&gt;
        &lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;if&lt;/span&gt; (rowsCount &amp;lt;= 50)
            &lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;return true&lt;/span&gt;;
        &lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;else&lt;/span&gt; {
            alert(&lt;span style="font-family: 'courier new'; color: #a31515; font-size: 9pt"&gt;"Exported rows are greater than 50 rows."&lt;/span&gt;);
            &lt;span style="font-family: 'courier new'; color: blue; font-size: 9pt"&gt;return false&lt;/span&gt;;
        }
    }
}&lt;/pre&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;Hope this helps. Please let us know if you have different requirement.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Export the ability to stop InitializePostBack Action..</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Export-the-ability-to-stop-InitializePostBack-Action/</link><pubDate>Thu, 22 Jul 2010 12:23:42 GMT</pubDate><dc:creator>tlusby</dc:creator><description>&lt;p&gt;I have a scenario that I want to check the record count before exporting the data.  If the record count is beyond what I want to allow, then I would like to stop the process.  I was hoping to do it in the &lt;span style="font-size: 13px"&gt;
&lt;p&gt;WebGrid1_InitializePostBack because this is called anyway when you click the Export button.  I would like to make one trip from the Client to the code behind.&lt;/p&gt;
&lt;p&gt;So I have this in the InitializePostBack ..&lt;/p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;WebGrid1_InitializePostBack because this is called anyway when you click the Export button.  I would like to make one trip from the Client to the code behind.&lt;/p&gt;
&lt;p&gt;So I have this in the InitializePostBack ..&lt;/p&gt;&lt;pre&gt;if (e.Action == PostBackAction.Export)
                {
                    if (((DataView)e.DataSource).Count &amp;gt; 6000)
                    {                        
                        ISNet.WebUI.FunctionParameter[] prms = new ISNet.WebUI.FunctionParameter[1];
                        prms[0] = new ISNet.WebUI.FunctionParameter("dummy", "string");
                        e.Grid.ClientAction.InvokeScript("ExportIssues", prms);
                        //[HERE I WANT TO STOP THE EXPORT PROCESS} 
                    }
                }&lt;/pre&gt;
&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;  &lt;/span&gt;</description></item></channel></rss>