PDA

View Full Version : [CLOSED] send store data items to directmethod



snow_cap
Sep 29, 2013, 7:03 PM
Hello,

Is it possible to send store data items to direct method as parameter.

I have the following:



<ext:Panel runat="server" Region="South">

<TopBar>
<ext:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext:Button ID="Button1" runat="server" Text="Save" Icon="Disk">
<Listeners>
<Click Handler="Save()"></Click>
</Listeners>


</ext:Button>
<ext:ToolbarSeparator ID="ToolbarSeparator1" runat="server" />
<ext:Button ID="Button2" runat="server" Text="Back" Icon="ArrowLeft"></ext:Button>
</Items>
</ext:Toolbar>
</TopBar>



<Items><ext:GridPanel
ID="GridPanelProduct"
runat="server"
Height="300"
Frame="true"
Title="Products">
<Store>
<ext:Store ID="Store1" runat="server">
<Sorters>
<ext:DataSorter Property="start" Direction="ASC" />
</Sorters>
<Model>
<ext:Model ID="Model1" runat="server" Name="Product">
<Fields>
<ext:ModelField Name="Product" ServerMapping="Product" Type="Int" />
<ext:ModelField Name="Quantity" ServerMapping="Quantity" Type="Int" />
<ext:ModelField Name="Amount" ServerMapping="Start" Type="Int" />


</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<Plugins>
<ext:RowEditing ID="RowEditing1" runat="server" ClicksToMoveEditor="1" AutoCancel="false" />
</Plugins>
<TopBar>
<ext:Toolbar ID="Toolbar2" runat="server">
<Items>
<ext:Button ID="Button3" runat="server" Text="Add Product" Icon="PackageAdd">
<Listeners>
<Click Fn="addEmployee" />
</Listeners>
</ext:Button>
<ext:Button ID="btnRemoveEmployee" runat="server" Text="Remove Product" Icon="PackageDelete" Disabled="true">
<Listeners>
<Click Fn="removeEmployee" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<ColumnModel>
<Columns>
<ext:RowNumbererColumn ID="RowNumbererColumn1" runat="server" Width="25" />
<ext:Column ID="Column1" runat="server"
Text="Product"
DataIndex="Product">
<Editor>
<ext:ComboBox runat="server" ID="CmbProduct" DisplayField="Name" ValueField="Id">
<Store>
<ext:Store runat="server" ID="ProductStore">
<Model>
<ext:Model ID="Model2" runat="server" IDProperty="Id">
<Fields>
<ext:ModelField Name="Id" Type="Int" ServerMapping="Id" />
<ext:ModelField Name="Name" Type="String" ServerMapping="Name" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
</ext:ComboBox>
</Editor>
</ext:Column>




<ext:NumberColumn ID="NumberColumn1"
runat="server"
Text="Amount"
DataIndex="Amount"
Format="$0,0">
<Editor>
<ext:NumberField ID="NumberField1"
runat="server"
AllowBlank="false"
MinValue="1"
MaxValue="150000" />
</Editor>
</ext:NumberColumn>
<ext:NumberColumn ID="NumberColumn2"
runat="server"
Text="Quantity"
DataIndex="Quantity">
<Editor>
<ext:NumberField ID="NumberField2"
runat="server"
AllowBlank="false"
MinValue="1"
MaxValue="150000" />
</Editor>
</ext:NumberColumn>
</Columns>
</ColumnModel>
<Listeners>
<SelectionChange Handler="#{btnRemoveEmployee}.setDisabled(!selected.length) ;" />
</Listeners>
</ext:GridPanel>
</items></ext:panel>


Javascript function :


function Save() {
//App.Store1.data.items
App.direct.Save(App.Store1.data.items);
}


Code Behind:


[DirectMethod]
public void Save(JsonObject values)
{

}


The thing is I don't think the type should be JsonObject.Any ideas?

Thank you

snow_cap
Sep 29, 2013, 7:13 PM
Sorry I found the solution:

It should be


function Save() {
//App.Store1.data.items
App.direct.Save(App.GridPanelProduct.getRowsValues ());
}


And I should create a class in code behind that takes the model fields as properties or JsonObject [].

Should I remove the post?

Baidaly
Sep 29, 2013, 10:07 PM
Hello!

Thank you for sharing your solution. Here is example that uses the same approach: http://examples2.ext.net/#/GridPanel/Selection_Models/Submitting_Values/

We usually keep posts because they can be useful somebody who has the same problem.