获取CheckboxGridPanel选中的行值,ext.net C#?

时间:2011-10-31 11:48:02

标签: c# ext.net

我正在使用Ext.net 1.2 == ExtJs 3.4.0

我想将所选值(使用名称,Lname过滤)添加到分机的文本框中 我搜索过,我可以找到下面的代码,但现在我不知道如何将JavaScript中var值的值添加到ext的文本框中。

<script type="text/javascript">
    function AddUser() {
        var values = GridPanel1.getRowsValues(
        {
            filterField: function (record, fieldName, value) {return fieldName == "Name" || fieldName == "Lname";},
            selectedOnly: true,
            currentPageOnly: false
        });
        ////this method should be complete
    }
</script>

<div style="width: 500px; margin: 0 auto;">
    <ext:Store ID="Store1" runat="server" OnRefreshData="Store1_RefreshData">
        <Reader>
            <ext:JsonReader IDProperty="ID">
                <Fields>
                    <ext:RecordField Name="ID" Type="Int" />
                    <ext:RecordField Name="RowNumber" Type="Int" />
                    <ext:RecordField Name="Name" />
                    <ext:RecordField Name="Lname" />
                    <ext:RecordField Name="EnterprisePosition" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <br />
    <ext:GridPanel ID="GridPanel1" runat="server" StoreID="Store1" StripeRows="true"
        Title="Result" Collapsible="true" StyleSpec="width:95%; margin:0 auto;"
        Height="350" Collapsed="true">
        <ColumnModel ID="ColumnModel1" runat="server">
            <Columns>
                <ext:Column ColumnID="RowNumber" Header="Row" Width="50" Resizable="false" MenuDisabled="true"
                    Fixed="true" DataIndex="RowNumber" />
                <ext:Column ColumnID="Name" Header="Name" Width="100" DataIndex="Name" />
                <ext:Column Header="Last Name" Width="150" DataIndex="Lname" />
                <ext:Column Header="Position" Width="160" DataIndex="EnterprisePosition" />
            </Columns>
        </ColumnModel>
        <BottomBar>
            <ext:PagingToolbar ID="PagingToolBar1" runat="server" PageSize="10" StoreID="Store1"
                DisplayInfo="false" />
        </BottomBar>
        <SelectionModel>
            <ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server">
                <Listeners>
                    <RowSelect Fn="AddUser" /><!-- ******** -->
                </Listeners>
            </ext:CheckboxSelectionModel>
        </SelectionModel>
    </ext:GridPanel>
</div>

我该怎么做?

1 个答案:

答案 0 :(得分:4)

我在Sencha forums找到了答案。 完整的功能如下:

<script type="text/javascript">
    function AddUser() {
        Ext.getCmp('TextFieldReceivers').setValue("");
        var count = Ext.getCmp('GridPanel1').getSelectionModel().getCount();
        var lst = Ext.getCmp('GridPanel1').getSelectionModel().getSelections();
        var textfiled = Ext.getCmp('TextFieldReceivers');
        for (var i = 0; i < count; i++) {
            textfiled.setValue(textfiled.value + lst[i].data.Name + " " + lst[i].data.Lname + ",");
        }
    }
</script>