Update different GridPanels within a DataList.

  1. #1

    Update different GridPanels within a DataList.

    I have serveral GridPanels for different priceclasses in a DataList and one central button so save them all.

    I am not able to save the GridPanels back to the SQL Server, because I don't know their names for a click handler of the button, like when I have just one "static" GridPanel (<ClickHandler="#{GridPanel_WholesalePrices}.save( );"/>)

    Hope the code is not too long:

                                        <asp:DataList ID="DataList_RetailPriceClasses" runat="server" DataSourceID="SqlDataSource_RetailPriceClasses"
                                            RepeatDirection="Horizontal" RepeatLayout="table" RepeatColumns="3" DataKeyField="PriceClassId">
                                            <SeparatorTemplate>
                                                &nbsp;</SeparatorTemplate>
                                            <ItemTemplate>
                                                <!------------------------------------------------------------------------------------------------------------------------------------------>
                                                <asp:SqlDataSource ID="SqlDataSource_RetailPrices" runat="server" ConnectionString="<%$ ConnectionStrings:RemoteSqlServer %>"
                                                    SelectCommand="SELECT [Id], [StartQuantity], [Price], [LastChange] FROM [vw_Erp_RetailPrices] 
                                               WHERE ([ShopId] = @ShopId)
                                               AND ([ItemId] = @ItemId)
                                               AND ([PriceClassId] = @PriceClassId)
                                               ORDER BY [StartQuantity]" UpdateCommand="UPDATE [shop_RetailPrices] SET
                                    StartQuantity = ISNULL(@StartQuantity,1), 
                                    Price = @Price, 
                                    LastChange = @CurrentDate
                                    WHERE (Id = @Id)">
                                                    <SelectParameters>
                                                        <asp:Parameter Name="ShopId" Type="Int16" />
                                                        <asp:Parameter Name="ItemId" Type="Int64" />
                                                        <asp:Parameter Name="PriceClassId" Type="Int16" />
                                                    </SelectParameters>
                                                    <UpdateParameters>
                                                        <asp:Parameter Name="StartQuantity" Type="Int16" />
                                                        <asp:Parameter Name="Price" Type="Decimal" />
                                                        <asp:Parameter Name="CurrentDate" Type="DateTime" />
                                                    </UpdateParameters>
                                                </asp:SqlDataSource>
                                                <!------------------------------------------------------------------------------------------------------------------------------------------>
                                                <ext:GridPanel ID="GridPanel_RetailPrices" runat="server" Height="200" ClicksToEdit="1"
                                                    ColumnLines="true">
                                                    <Store>
                                                        <ext:Store ID="Store_RetailPrices" runat="server" RefreshAfterSaving="Always">
                                                            <DirectEvents>
                                                            </DirectEvents>
                                                            <Reader>
                                                                <ext:JsonReader AutoDataBind="false" IDProperty="Id">
                                                                    <Fields>
                                                                        <ext:RecordField Name="Id" Type="Int">
                                                                        </ext:RecordField>
                                                                        <ext:RecordField Name="StartQuantity" Type="int">
                                                                        </ext:RecordField>
                                                                        <ext:RecordField Name="Price" Type="Float">
                                                                        </ext:RecordField>
                                                                        <ext:RecordField Name="LastChange" Type="Date">
                                                                        </ext:RecordField>
                                                                    </Fields>
                                                                </ext:JsonReader>
                                                            </Reader>
                                                            <Listeners>
                                                                <Exception Handler="
                                                                Ext.net.Notification.show({
                                                                    iconCls    : 'icon-exclamation', 
                                                                    html       : e.message, 
                                                                    title      : 'EXCEPTION', 
                                                                    autoScroll : true, 
                                                                    hideDelay  : 5000, 
                                                                    width      : 300, 
                                                                    height     : 200
                                                                });" />
                                                            </Listeners>
                                                        </ext:Store>
                                                    </Store>
                                                    <Plugins>
                                                        <ext:EditableGrid ID="EditableGrid1" runat="server" />
                                                    </Plugins>
                                                    <ColumnModel>
                                                        <Columns>
                                                            <ext:NumberColumn Header="Verkaufspreis" DataIndex="Price" Align="Right" Editable="true">
                                                                <Editor>
                                                                    <ext:NumberField ID="NumberField2" runat="server" AllowDecimals="true" DecimalPrecision="2"
                                                                        DecimalSeparator="," AllowNegative="false">
                                                                    </ext:NumberField>
                                                                </Editor>
                                                            </ext:NumberColumn>
                                                            <ext:Column Header="Stückzahl" DataIndex="StartQuantity" Align="Right" Editable="true">
                                                                <Editor>
                                                                    <ext:NumberField ID="NumberField1" runat="server" AllowDecimals="false" AllowNegative="false">
                                                                    </ext:NumberField>
                                                                </Editor>
                                                            </ext:Column>
                                                            <ext:CommandColumn>
                                                                <Commands>
                                                                    <ext:GridCommand Icon="Delete" CommandName="Delete" Text="Löschen" />
                                                                </Commands>
                                                            </ext:CommandColumn>
                                                        </Columns>
                                                    </ColumnModel>
                                                    <SelectionModel>
                                                        <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true" />
                                                    </SelectionModel>
                                                    <Listeners>
                                                        <Command Handler="#{GridPanel_RetailPrices}.getStore().remove(record);" />
                                                    </Listeners>
                                                    <Buttons>
                                                        <ext:Button ID="btnInsert" runat="server" Text="Preis Hinzufügen" Icon="Add">
                                                            <Listeners>
                                                                <Click Handler="#{GridPanel_RetailPrices}.insertRecord(0, {});#{GridPanel_RetailPrices}.getView().focusRow(0);#{GridPanel_RetailPrices}.startEditing(0, 0);" />
                                                            </Listeners>
                                                        </ext:Button>
                                                    </Buttons>
                                                </ext:GridPanel>
                                            </ItemTemplate>
                                        </asp:DataList>
    Any ideas?

    Jan
    Last edited by joshihybrid; Jan 06, 2011 at 11:30 PM.

Similar Threads

  1. Not all GridPanels are resizing
    By chris.salas in forum 1.x Help
    Replies: 0
    Last Post: Jan 25, 2011, 2:10 PM
  2. Replies: 3
    Last Post: Jul 24, 2010, 10:36 AM
  3. [CLOSED] XmlDataSource & DataList Coolite Alternative
    By fondant in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 08, 2010, 7:32 AM
  4. BUG - tabPanel with 2 gridpanels
    By RPIRES in forum 1.x Help
    Replies: 0
    Last Post: Jul 01, 2010, 6:15 PM
  5. Replies: 0
    Last Post: Jan 06, 2010, 6:41 AM

Posting Permissions