PDA

View Full Version : Problem with Update ASP "Formview" and Coolite "Gridpanel" in one aspx



Simon King
Dec 16, 2008, 6:29 AM
Hi all, I've try to use coolite coding on a asp.net page which need access/update on one master table and a linked subtable, same structure as [order] and [orderdetail].
The page "OrderDetail.aspx" is intend to provide view/update function in one page, I use asp:formview to display data from SQL datasource, and use ext:GridPanel to show orderdetail grid.

When user create a new order, input order detail on grid and click submit button, I need to call FormViewOrder.InsertItem() to insert data in master table, and get the new id @id from reture value, then update all OrderId in subtable and save, via call client function #{GridPanelOrderList}.save() in listener.

I try to attach the AjaxEvents and Listener in one button, but they seems work seperately, so cause new OrderID can't be retrieve when gridpanel update. For temp solition, I split them in too button, just like below:



...

<asp:SqlDataSource ID="SqlDataSourceOrder" runat="server"
ConnectionString="xxxxxxxx"
selectcommand = "SELECT * FROM TB_Order"
......
>
</asp:SqlDataSource>


<asp:SqlDataSource ID="SqlDataSourceOrderDetail" runat="server"
ConnectionString="xxxxxxxx"
selectcommand = "SELECT * FROM TB_OrderDetail where OrderID=xxx"
OnInserted="SqlDataSourceOrder_Inserted"
......
>
</asp:SqlDataSource>


<ext:Store ID="StoreOrderDetail" runat="server" DataSourceID="SqlDataSourceOrderDetail"
OnBeforeRecordInserted ="StoreOrderDetail_BeforeRecordInserted"
>
<Reader>
<ext:JsonReader ReaderID="OrderDetailID">
<Fields>
<ext:RecordField Name="OrderID" />
......
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>

...

<asp:FormView ID="FormViewOrder" runat="server" DataKeyNames="OrderID" DataSourceID="SqlDataSourceOrder" DefaultMode="Insert">
<ItemTemplate>
......
</ItemTemplate>
<InsertItemTemplate>
</InsertItemTemplate>
</asp:FormView>

<ext:GridPanel ID="GridPanelOrderDetail" runat="server" StoreID="StoreOrderDetail"
...
>

...

<ext:Button ID="btnNext1" runat="server" Text="Save Order" Icon="Accept">
<AjaxEvents>
<Click OnEvent="SaveOrder">
</AjaxEvents>
</ext:Button>

<ext:Button ID="btnNext2" runat="server" Text="Save Order Detail" Icon="Accept">
<Listeners>
<Click Handler="#{GridPanelOrderDetail}.save();" />
</Listeners>
</ext:Button>


My question are:
1. how can I combine they together ?
2. I fell it's not a good solution to use formview and gridpanel together, because they are using different programing method, is there any solution in coolite to replace forview/detail view work with datasource and store?

Pls kindly help, thanks a lot!

mindcore1
Dec 16, 2008, 11:56 AM
Have you taken a look at these examples:

http://examples1.ext.net/#/GridPanel/DataSource_Update/SqlDataSource/

http://examples1.ext.net/#/GridPanel/Data_with_Details/Form_Details/

The first demonstrate how to bind editable data from a SqlDataSource to an ext:GridPanel control while handling the inserting, updating and deleting using Ajax.

And the second demonstrates how to bind a FormGroup to a GridPanel selection.

Simon King
Dec 16, 2008, 1:40 PM
Dear mindcore1, thanks for your reply, but it semmes not what I need, my problem is the different update method of formview and gridpanel. Also the 2nd example is list / detail view, the value in detail form is update one by one in event handler, not binding with store or datasource, so not same problem in my coding.
Any way, still thanks a lot.

kumarxlnt
Sep 18, 2009, 5:31 AM
Hi Simon,

Have you found any solution?. I am also in need of same thing.

If so then please share with me.

Thanks