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

AJAX postback disable

7 Answers 224 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Roman Krsko
Top achievements
Rank 1
Roman Krsko asked on 10 Sep 2010, 12:30 PM
Hi,

I have problem with ajax postback. Is possible to cancel ajax postback after refresh grid.

I have grid and I use this code:
function RefreshGrid(search) {
  if (search != "") {
    document.getElementById("search").value = search;
    var masterTable = $find("<%= grdResult.ClientID %>").get_masterTableView();
    masterTable.rebind();
  }
}
 
function requestStart(sender, eventArgs) {
     document.getElementById("ajaxrequest").value = "true";
}
function responseEnd(sender, eventArgs) {
    document.getElementById("ajaxrequest").value = "false";
}

But problem is, that I refresh grid, all page codebehind are called. Not only webservice (use it for reading data).
In PageLoad I use
sAjaxRequest = Request.Params["ajaxrequest"] + "";
if (sAjaxRequest != "true")
{
     //... loading controls and set property from DB (radcombo, radgrid, ...)
}

Grid
<telerik:RadGrid ID="grdResult" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" GridLines="None" onitemdatabound="grdResult_ItemDataBound" PageSize="20" Width="100%" DataSourceID="GridDataSource" BorderStyle="None">
 <PagerStyle Mode="NextPrevAndNumeric" PageButtonCount="10" />
   <ClientSettings AllowDragToGroup="True" EnableRowHoverStyle="true">
   <DataBinding EnableCaching="true" />
   <Selecting AllowRowSelect="true" />
   <ClientEvents /></ClientSettings>
   <HeaderContextMenu enableautoscroll="True"></HeaderContextMenu>
   <MasterTableView>
      <Columns>
         <telerik:GridBoundColumn DataField="Manufacturer" HeaderText="Manufacturer" UniqueName="colManufacturer"></telerik:GridBoundColumn>
         <telerik:GridBoundColumn DataField="Stock" DataFormatString="{0:0}" HeaderStyle-HorizontalAlign="Right" HeaderText="Stock" ItemStyle-HorizontalAlign="Right" UniqueName="Stock"></telerik:GridBoundColumn>
         <telerik:GridBoundColumn DataField="Price" HeaderStyle-HorizontalAlign="Right" HeaderText="Price" ItemStyle-HorizontalAlign="Right" UniqueName="Price"></telerik:GridBoundColumn>
        </Columns>
      </MasterTableView>
</telerik:RadGrid>
<asp:ObjectDataSource ID="GridDataSource" runat="server" SelectMethod="FillResultGrid" TypeName="shop.Service">
  <SelectParameters>
    <asp:FormParameter FormField="search" Name="sSearch" Type="String" />
  </SelectParameters>
</asp:ObjectDataSource>

Problem is, that I don't set combos data and property, then I receive blank controls after ajax.
Ajax framework set my controls, but I don't want it.

Thanks for answer.
Roman Krsko

7 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 10 Sep 2010, 01:35 PM
Hello Roman,

The main difference between regular postback and ajax callback is that only part of the page html is send back on the client after ajax request. However you should note that the page lifecycle is executed the same way with postback or callback.
Thus if you are using a web service for extracting data, I would suggest that you consider binding the RadGrid client-side. Find the below online demos for a reference:

http://demos.telerik.com/aspnet-ajax/grid/examples/client/livedata/defaultcs.aspx
http://demos.telerik.com/aspnet-ajax/grid/examples/client/declarativedatabinding/defaultcs.aspx

Best wishes,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Roman Krsko
Top achievements
Rank 1
answered on 12 Sep 2010, 04:46 PM
Hi,

I try this samples, but I don't know, how to use it. I receive always error code
Error: Sys.ArgumentException: Cannot deserialize. The data does not correspond to valid JSON.
Parameter name: data
Source file : http://localhost/webshop/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=radScriptManager_TSM&compress=1&_TSM_CombinedScripts_= %3b%3bSystem.Web.Extensions%2c+Version%3d3.5.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3ad0c ...


This is webservice code
[WebMethod(EnableSession = true)]
public DataSet FillResultGrid()
{
  try
  {
     DataSet dsSearch = new DataSet();
     ...
     return dsSearch;
  }
  catch { ... }
}

This is code of grid
<telerik:RadGrid ID="grdResult" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" GridLines="None" PageSize="20" Width="100%" BorderStyle="None">
 <PagerStyle Mode="NextPrevAndNumeric" PageButtonCount="10" />
   <MasterTableView>
      <Columns>
         <telerik:GridBoundColumn DataField="Manufacturer" HeaderText="Manufacturer" UniqueName="colManufacturer"></telerik:GridBoundColumn>
         <telerik:GridBoundColumn DataField="Stock" DataFormatString="{0:0}" HeaderStyle-HorizontalAlign="Right" HeaderText="Stock" ItemStyle-HorizontalAlign="Right" UniqueName="Stock"></telerik:GridBoundColumn>
         <telerik:GridBoundColumn DataField="Price" HeaderStyle-HorizontalAlign="Right" HeaderText="Price" ItemStyle-HorizontalAlign="Right" UniqueName="Price"></telerik:GridBoundColumn>
        </Columns>
      </MasterTableView>
      <ClientSettings EnableRowHoverStyle="true">
         <Selecting AllowRowSelect="true" />
         <DataBinding EnableCaching="true" Location="~/WebshopService.asmx" SelectMethod="FillResultGrid" />
         <ClientEvents OnDataBinding="grdResult_DataBinding" />
       </ClientSettings>
</telerik:RadGrid>

What I do bad?
Thanks for answer.

Roman
0
Iana Tsolova
Telerik team
answered on 13 Sep 2010, 11:16 AM
Hello Roman,

Try modifying the FillResultGrid method so it returns Dictionary object as the GetDataAndCount() method from the attached WebService and see if it makes any difference? Note that the same WebService is used for the second RadGrid data-binding in this demo.

Greetings,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Roman Krsko
Top achievements
Rank 1
answered on 13 Sep 2010, 06:40 PM
Hello Lana,

I copied my sample to the demo project, and it was running successful.
Trying run the same sample in my project I still receive the posted error.
Trying to copy a telerik sample into my project fails also.
I'm not sure missing an entry in the Web.config.

Roman
0
Iana Tsolova
Telerik team
answered on 14 Sep 2010, 01:21 PM
Hello Roman,

Based on the provided information so far I am not sure what could have gone wrong in your case. Therefore I suggest that you open a formal support ticket and either send us a runnable project or at least the problematic pages, and code files for further research.

Sincerely yours,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Roman Krsko
Top achievements
Rank 1
answered on 21 Sep 2010, 02:25 PM
Hi Lana,

thanks for your help, I solve this problem.
Problem was, that inside grid is default property DataBinding-CountPropertyName set as  "Count" and DataBinding-DataPropertyName="Data", but this is not visible inside aspx and I use own names.

But I have another question. Is possible use other means of fill data as list of objects? For example DataSet or XML for Client-side databinding. Or can I use xml and then transform with javascript to necessary structures.
Both two samples (Client-side databinding) are only with list of objects, but I need something dynamically (XML, DataSet).
Thanks.

Roman
0
Iana Tsolova
Telerik team
answered on 24 Sep 2010, 08:53 AM
Hello Roman,

If you want to bind the grid to Xml, I would suggest that you use server-side binding.
Otherwise you can consider implementing your scenario in MVC.

Best wishes,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Roman Krsko
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Roman Krsko
Top achievements
Rank 1
Share this question
or