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

[Solved] Clientside Rebind dosn't clear cache

2 Answers 275 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kent Williams
Top achievements
Rank 1
Kent Williams asked on 12 Aug 2009, 09:35 PM

Hi,

I have implimented a grid using webservices for client-side binding. I created an additional method that allows me to update rows via the webservice as well. Upon recipt of successful update, the grid is supposed to rebind. This only seems to work if clientside caching is disabled. Is this a bug - or is there a clientside method/property I can call to clear the cache?

Thanks,

Kent

<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">  
<script type="text/javascript">  
    function RowSelected(sender, eventArgs)  
    {         
        //Enable the update tab  
        var tabStrip= $find("<%= RadTabStrip1.ClientID %>");  
        var tab = tabStrip.findTabByText("Update");  
        tab.set_enabled(true);  
          
        //Get references to the input fields  
        var costCenterGID = document.getElementById("<%= costCenterGID.ClientID %>");  
        var costCenterNo = $find("<%= costCenterNo.ClientID %>");  
        var costCenterDesc = $find("<%= costCenterDesc.ClientID %>");  
          
        costCenterGID.innerHTML = eventArgs.getDataKeyValue("CostCenterGID");  
        costCenterNo.set_value(eventArgs.getDataKeyValue("CostCenterNo"));  
        costCenterDesc.set_value(eventArgs.getDataKeyValue("CostCenterDesc"));  
    }  
    function RowUpdate()  
    {  
        //Get references to the input fields  
        var costCenterGIDctrl = document.getElementById("<%= costCenterGID.ClientID %>");  
        var costCenterDescctrl = $find("<%= costCenterDesc.ClientID %>");  
          
        //Get the values  
        var costCenterGID = costCenterGIDctrl.innerHTML;  
        var costCenterDesc = costCenterDescctrl.get_value();  
          
        //Invoke the webservice to update  
        Caspr.WebServices.accountingUnitsWebService.UpdateData(costCenterGID, costCenterDesc, UpdateSucceededCallback);  
    }  
    function UpdateSucceededCallback(result, eventArgs)  
    {  
        alert("Updated? " + result);  
        if (result)  
        {  
            RefreshGrid();  
        }  
    }  
    function RefreshGrid()  
    {  
      var masterTable = $find("<%= auGrid.ClientID %>").get_masterTableView();  
      masterTable.rebind();  
    }   
</script> 
</telerik:RadScriptBlock> 

<ClientSettings> 
    <DataBinding Location="http://localhost/dnn/DesktopModules/Caspr/Webservices/accountingUnitsWebService.asmx" 
        SelectMethod="GetData" 
        CountPropertyName="Count" 
        DataPropertyName="Data" 
        FilterParameterType="Linq" 
        SortParameterType="Linq" 
        EnableCaching="true" /> 
    <Selecting AllowRowSelect="true" /> 
    <ClientEvents  
        OnRowSelected="RowSelected" 
        /> 
</ClientSettings> 

2 Answers, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 13 Aug 2009, 04:25 PM
To me it sounds like a possibility that the EnableCaching="true" attribute of the <DataBinding> tags might be the problem. Since when you do the rebind() it might attempt to go to the cache for the information instead of going to the server. The EnableCaching attribute does work nicely in terms of performance since all the necessary information can be stored in cache,but for this case it seems like you might need to talk to the server instead of going to cache to find the information. Not sure if this will break your client-side binding or not though.

Alternatively you might have to use a fireCommand for the rebind instead of a normal .rebind(), check out this article about it:
http://www.telerik.com/help/aspnet-ajax/grid_firecommand.html



0
Kent Williams
Top achievements
Rank 1
answered on 13 Aug 2009, 04:40 PM
Hi Schlurk.
Thanks for the reply. I agree that the problem is with the EnableCaching="true" markup. Everything works great with it set to false, however I am after that nice performance boost you get with it turned on. What I seem to need is a way to invalidate the cache - or to clear it. For my particular scenerio I could do a direct cell update, however in other situations I will have calculated columns, etc. that would require a true rebind of the data.

I have investigated the fireCommand() as you suggested. I tried several of them to see if they would invalidate the cache. Almost all of the commands I tried were simply ignored (probebly due to the client-side binding). I did not see any commands used with fireCommand() that would cause a rebind.

Thanks,

Kent
Tags
Grid
Asked by
Kent Williams
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
Kent Williams
Top achievements
Rank 1
Share this question
or