How does xaf extend the application model editing? listview automatically saves

Source: Internet
Author: User

 

 

Using system;
Using system. componentmodel;
Using system. Collections. Generic;
Using system. diagnostics;
Using system. text;

Using devexpress. expressapp;
Using devexpress. expressapp. actions;
Using devexpress. Persistent. base;
Using devexpress. expressapp. model;
Using devexpress. expressapp. Win. systemmodule;

Namespace xafextendtest. Module. systemmodule
{
Public interface imodelclassautocommitlistview: imodelnode
{
[Category ("mycustomproperty")]
[Description ("control if change on editable listview will be autocommited")]
Bool autocommitlistview {Get; set ;}
}
[Modelinterfaceimplementor (typeof (imodelclassautocommitlistview), "modelclass")]
Public interface imodellistviewautocommitlistview: imodelclassautocommitlistview
{
}
Public class autocommitlistviewcontroller: viewcontroller <listview>, imodelextender
{
Protected override void onviewcontrollersactivated ()
{
Base. onactivated ();
VaR windetailviewcontroller = frame. getcontroller <windetailviewcontroller> ();
If (windetailviewcontroller! = NULL & (imodellistviewautocommitlistview) view. Model). autocommitlistview)
{
Windetailviewcontroller. autocommitlistview = true;
View. querycanchangecurrentobject + = view_querycanchangecurrentobject;
}
}

Void view_querycanchangecurrentobject (Object sender, canceleventargs E)
{
If (frame. getcontroller <windetailviewcontroller> (). suppressconfirmation)
Objectspace. commitchanges ();
}

Protected override void ondeactivated ()
{
Base. ondeactivated ();
VaR windetailviewcontroller = frame. getcontroller <windetailviewcontroller> ();
If (windetailviewcontroller! = NULL & (imodellistviewautocommitlistview) view. Model). autocommitlistview)
{
Windetailviewcontroller. autocommitlistview = true;
View. querycanchangecurrentobject-= view_querycanchangecurrentobject;
}
}
Void imodelextender. extendmodelinterfaces (modelinterfaceextenders extenders)
{
Extenders. Add <imodelclass, imodelclassautocommitlistview> ();
Extenders. Add <imodellistview, imodellistviewautocommitlistview> ();
}
}
}

 

Welcome to reprint, reprint please indicate the source: http://www.cnblogs.com/Tonyyang/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.