Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to perform a RowClick (ExtNet Store) in runtime

Tags:

c#

ext.net

I have 2 grids, and the second is many to one form the first grid's rows, so, whenever I load the page, I need a row selected in the first grid.

I tried to do this:

X.Call("myFunctionRowSelectJS(#{grpMyGridStore});");

but is'nt working, did I forget something? is there any alternative way in C#?

like image 999
maxgomes Avatar asked Nov 22 '17 13:11

maxgomes


1 Answers

How about this:

*.aspx

<ext:GridPanel ID="grid" runat="server">
    <ColumnModel>
        <Columns>
            <ext:Column runat="server" DataIndex="Field1" />
        </Columns>
    </ColumnModel>
    <Store>
        <ext:Store runat="server" ID="store">
            <Model>
                <ext:Model runat="server">
                    <Fields>
                        <ext:ModelField Name="Field1" />
                    </Fields>
                </ext:Model>
            </Model>
        </ext:Store>
    </Store>
    <SelectionModel>
        <ext:RowSelectionModel runat="server">
            <Listeners>
                <Select Handler="Ext.Msg.alert('Info', 'I was selected!');" />
            </Listeners>
        </ext:RowSelectionModel>
    </SelectionModel>
</ext:GridPanel>

*.aspx.cs

protected void Page_Load(object sender, EventArgs e)
{
    store.DataSource = new object[] 
    { 
        new { Field1 = "Row 1" },
        new { Field1 = "Row 2" },
        new { Field1 = "Row 3" }
    };

    store.DataBind();

    RowSelectionModel selectionModel = grid.GetSelectionModel() as RowSelectionModel;
    selectionModel.SelectedIndex = 0; // Select first row
}
like image 66
Peska Avatar answered Sep 21 '22 17:09

Peska