GridPanel CheckboxSelectionModel - Add selection (ext.net)

-1

How can I add a particular column that is selected via java-script? I'm using ext.net.

        <script>
        var sumCheck= function () {
            var resultSum;

          /* todo loop selectedrows
             resultSum += column(field_value); */;

            alert(resultSum);
        };
    </script>

 <ext:GridPanel runat="server" ID="grid1" Height="250px" Frame="true" StoreID="dsGrid1">
                        <ColumnModel runat="server">
                            <Columns>
                                <ext:NumberColumn runat="server" DataIndex="field_value" Format=",0.00" Align="Right"/>                             
                            </Columns>
                        </ColumnModel>
                        <SelectionModel>
                            <ext:CheckboxSelectionModel runat="server" Mode="Multi">
                                <Listeners>
                                    <SelectionChange Fn="sumCheck()" />
                                </Listeners> 
                            </ext:CheckboxSelectionModel>
                        </SelectionModel>                       
</ext:GridPanel>

Thanks to anyone who can help me.

    
asked by anonymous 12.12.2017 / 17:40

1 answer

0

I was able to solve with the help of the stack in English, follow an example with the solution to help those who have the same doubt:

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!X.IsAjaxRequest)
        {
            this.Store2.DataSource = new object[]
            {
                new object[] { 'A', 20 },
                new object[] { 'B', 52 },
                new object[] { 'C', 36 }
            };
            this.Store2.DataBind();

        }
    }
</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>Ext.NET Example</title>
</head>
<body>
    <form runat="server">
        <ext:ResourceManager runat="server" />

        <ext:GridPanel runat="server">
            <Store>
                <ext:Store ID="Store2" runat="server">
                    <Model>
                        <ext:Model runat="server" AutoDataBind="true">
                            <Fields>
                                <ext:ModelField Name="product" />
                                <ext:ModelField Name="price" />
                            </Fields>
                        </ext:Model>
                    </Model>

                    <Reader>
                        <ext:ArrayReader />
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column runat="server" Header="Product" DataIndex="product" Flex="1" />
                    <ext:Column runat="server" Header="Price ($)" DataIndex="price" Flex="1" />
                </Columns>
            </ColumnModel>
                        <SelectionModel>
                <ext:CheckboxSelectionModel runat="server" Mode="Multi">
                    <Listeners>
                        <SelectionChange Handler="var total = 0;
                                                  var grid = this;
                                                  var selected = grid.getSelection();;
                                                  Ext.Array.forEach(selected, function (rec) {
                                                      total += rec.get('price');
                                                   });
                            alert(total);
                            " />
                    </Listeners>
                </ext:CheckboxSelectionModel>
            </SelectionModel>


        </ext:GridPanel>


    </form>
</body>
</html>
    
16.12.2017 / 14:10