Gridpanel Checkboxselectionmodel - Sum selection (ext.net)

Asked

Viewed 56 times

-1

How can I add a particular column q this selected, via java-script? I am 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>

Thank you to anyone who can help me.

  • hello, you are using Stackoverflow in English, use the correct language or go to https://stackoverflow.com/

  • It was bad.. custom to use the forum in English.

1 answer

0


I managed to solve with the help of the stack in English, follows 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>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.