[SOLVED] gridpanel refresh - directmethod
New Community Forums available at http://forums.ext.net
 

Coolite Forums

Welcome Guest ( Login | Register )
 
[SOLVED] gridpanel refresh - directmethod
Subscribe
Last Login: 6/25/2010 9:58:51 AM
Posts: 78,
Posted 6/22/2010 2:14:24 PM

Group: Coolite Premium Member & Early Adopter
I have a combox. When select a value, getInfo function is called. Gridpanel is bind to store1.

I would like to repopulate the gridpanel using Ext.getCmp('gridPanel1').store.load();

I am not sure what is missing, I am not getting error messages, gridpanel doesn't show the store data.

Thanks for your help


[DirectMethod]

public void GetStore(string id)


{



....
.....
this
.Store1.DataSource = datatable1;


this.Store1.DataBind();



}

js function:


var getInfo = function (key)


{


Ext.net.DirectMethods.GetStore(


key,


{


success: function () {




try


{



Ext.getCmp('gridPanel1').store.load();



}


catch(Error)


{


}


},


failure: function(){


Ext.Msg.alert('Failure', 'System error, Please contact admin.');


},


eventMask: {


showMask: true,


minDelay: 500


}


});



}



Last Login: 7/5/2010 5:02:39 AM
Posts: 67,
Posted 6/23/2010 9:17:59 AM

Group: Coolite Premium Member & Early Adopter
 Hello, vali1993!

I used your DirectMethod GetStore and js function getInfo in my example. It works fine. Please look at this.


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="gridpanel refresh - directmethod.aspx.cs"
    Inherits="Work.gridpanel_refresh___directmethod" %>


<%@ Import Namespace="System.Collections.Generic" %>
<script runat="server">
    [DirectMethod]
    public void GetStore(string id)
    {
        List<Company> datatable1 = new List<Company>
             {
                 new Company("3m Co", 71.72, 0.02, 0.03),
                 new Company("Alcoa Inc", 29.01, 0.42, 1.47),
                 new Company("Altria Group Inc", 83.81, 0.28, 0.34),
                 new Company("American Express Company", 52.55, 0.01, 0.02),
                 new Company("American International Group, Inc.", 64.13, 0.31, 0.49),
                 new Company("AT&T Inc.", 31.61, -0.48, -1.54),
                 new Company("Boeing Co.", 75.43, 0.53, 0.71),
                 new Company("Caterpillar Inc.", 67.27, 0.92, 1.39),
             };
        this.Store1.DataSource = datatable1;
        this.Store1.DataBind();
    }

    public class Company
    {
        public Company(string name, double price, double change, double pctChange)
        {
            this.Name = name;
            this.Price = price;
            this.Change = change;
            this.PctChange = pctChange;
        }

        public string Name { get; set; }
        public double Price { get; set; }
        public double Change { get; set; }
        public double PctChange { get; set; }
    }
</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    <script type="text/javascript">
        var getInfo = function(key) {
            Ext.net.DirectMethods.GetStore(key,
            {
                success: function() {
                    try {
                  //Ext.getCmp("gridPanel1").store.load();   It's unnecessary action! Store1.DataBind() in the GetStore is enough
                    }
                    catch (Error) {
                    }
                },

                failure: function() {
                    Ext.Msg.alert('Failure', 'System error, Please contact admin.');
                },

                eventMask: {
                    showMask: true,
                    minDelay: 500
                }
            });
        }
    </script>

</head>
<body>
    <ext:ResourceManager runat="server"></ext:ResourceManager>
    <ext:Store ID="Store1" runat="server">
        <Reader>
            <ext:JsonReader>
                <Fields>
                    <ext:RecordField Name="Name" />
                    <ext:RecordField Name="Price" />
                    <ext:RecordField Name="Change" />
                    <ext:RecordField Name="PctChange" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:GridPanel ID="GridPanel1" runat="server" StoreID="Store1" StripeRows="true"
        Title="Company List" Width="600" Height="350" AutoExpandColumn="Company">
        <ColumnModel ID="ColumnModel1" runat="server">
            <Columns>
                <ext:Column ColumnID="Company" Header="Company" Width="160" DataIndex="Name" />
                <ext:Column Header="Price" Width="75" DataIndex="Price" />
                <ext:Column Header="Change" Width="75" DataIndex="Change" />
                <ext:Column Header="Change" Width="75" DataIndex="PctChange" />
            </Columns>
        </ColumnModel>
        <LoadMask ShowMask="true" />
    </ext:GridPanel>
    <ext:Button ID="Button1" runat="server" Text="Click Me" Icon="Lightning">
    <Listeners>
        <Click Handler="getInfo('Key');"/>
    </Listeners>
</ext:Button>
</body>
</html>


It seems something is wrong with the rest part of your code. Could I look at this? Perhaps the matter is how you invoke the getInfo function.

Please note that the code "Ext.getCmp("gridPanel1").store.load();" in the success handler is unnecessary. Invoking Store1.DataBind() is enough to refresh the GridPanel.

--
Best wishes,
Daniil Veriga

Last Login: 6/25/2010 9:58:51 AM
Posts: 78,
Posted 6/24/2010 1:45:41 PM

Group: Coolite Premium Member & Early Adopter
 Thanks for your reply. That was my initial thought. But when i tried it, the grid didn't refresh. Now I think there must be a mistake somewhere else. I ended up using directevent. it worked for me too.
« Prev Topic | Next Topic »
Reading This Topic
Active Users: 0 ( 0 guests, 0 members, 0 anonymous members )
No members currently viewing this topic.
All times are GMT -5:00, Time now is 1:44pm