PDA

View Full Version : [CLOSED] TreeGrid submit dirty rows



IMehl
Dec 02, 2014, 12:56 PM
Hi,

i have a TreeGrid without Store but with some columns with an editor. I can edit the data and the cell is marked as dirty.

Now i want to save the data. Is it possible to get all dirty rows as one Parameter?



<ext:Button runat="server" Icon="Disk" Text="Save">
<DirectEvents>
<Click OnEvent="SaveAllDirtyValues" >
<ExtraParams>
<ext:Parameter Name="RowValues" Value="#{TreeGrid1}.getValues({dirtyValuesOnly:true})" Mode="Raw" Encode="true" />
</ExtraParams>
</Click>
</DirectEvents>
</ext:Button>


best regards
I.

Daniil
Dec 03, 2014, 2:55 PM
Hi @IMehl,

Welcome to the Ext.NET forums

Please look at this example:
http://examples2.ext.net/#/GridPanel/Update/Batch/

There is the following Button:

<ext:Button runat="server" Text="Sync" Icon="Disk">
<DirectEvents>
<Click OnEvent="SaveClick" Before="return #{Store1}.isDirty();">
<ExtraParams>
<ext:Parameter Name="data" Value="#{Store1}.getChangedData()" Mode="Raw" Encode="true" />
</ExtraParams>
</Click>
</DirectEvents>
</ext:Button>

Here is the SaveClick method.

protected void SaveClick(object sender, DirectEventArgs e)
{
ChangeRecords<TestPerson> persons = new StoreDataHandler(e.ExtraParams["data"]).BatchObjectData<TestPerson>();

foreach (TestPerson created in persons.Created)
{
this.AddPerson(created);

ModelProxy record = Store1.GetByInternalId(created.PhantomId);

//remember record instance in variable to avoid searching on each method calling
record.CreateVariable = true;

record.SetId(created.Id);
record.Commit();
created.PhantomId = null;
}

foreach (TestPerson deleted in persons.Deleted)
{
this.DeletePerson(deleted.Id.Value);
Store1.CommitRemoving(deleted.Id.Value);
}

foreach (TestPerson updated in persons.Updated)
{
this.UpdatePerson(updated);
Store1.GetById(updated.Id.Value).Commit();
}
}

I would try this technique for a TreePanel as well.

As for not having TreeStore, it exists internally anyways.

<ext:Parameter Name="data" Value="App.TreePanel1.getStore().getChangedData()" Mode="Raw" Encode="true" />

IMehl
Dec 04, 2014, 5:55 AM
Hi Daniil,

thanks for your answer. It works fine so far. But in the TreeStore "Store1" there are no methods like
- GetByInternalId
- CommitRemoving
- GetById

And there is no .isDirty() function in the TreeStore.



<ext:Button runat="server" Text="Sync" Icon="Disk">
<DirectEvents>
<Click OnEvent="SaveAllValues" Before="return #{TreeGrid1}.getStore().isDirty();">
<ExtraParams>
<ext:Parameter Name="RowValues" Value="#{TreeGrid1}.getStore().getChangedData()" Mode="Raw" Encode="true" />
</ExtraParams>
</Click>
</DirectEvents>
</ext:Button>

These are only in the Store control. Has a TreeStore comparable methods?

best regards
I.

Daniil
Dec 04, 2014, 9:52 AM
Yes, it looks the TreeStore API is not quite ready for the Batch style of saving. Sorry for misleading you.

We recommend to consider a regular ExtJS saving mechanism.
http://examples2.ext.net/#/search/saving+variations
http://examples2.ext.net/#/GridPanel/Update/AutoSave/

The examples are for GridPanels, but it should work for TreePanels.

There is an alternative approach also built for TreePanels specifically.
http://examples2.ext.net/#/TreePanel/Advanced/Remote_Mode/
http://examples2.ext.net/#/TreePanel/Advanced/Remote_Mode_with_Service/

IMehl
Dec 09, 2014, 9:47 AM
Thanks, please mark this case as closed

best reagrds
I.