XPInstantFeedbackSource Class

A component that can be used as a data source for the GridControl and SearchLookUpEdit controls in Instant Feedback Mode.

XPInstantFeedbackSource类是可以给GridControl 和SearchLookUpEdit控件做数据源的一种即时回馈组件。

Namespace:DevExpress.Xpo
Assembly:DevExpress.Xpo.v12.2.dll

命名空间:DevExpress.Xpo,在程序集DevExrepss.Xpo.v12.2.dll

Remarks
Instant Feedback binding mode is an improvement over the regular server mode. In server mode, the XtraGrid loads data in small portions and delegates all data operations (sorting, grouping, filtering and calculating summaries) to the data server. This is the key to the server mode's high efficiency when working with large volumes of data. The only drawback to using server mode involves data operations when the connection to the server is slow. In this instance, the bound control freezes until the data server completes operations and retrieves results. With Instant Feedback binding mode, data operations are performed asynchronously in a background thread, and both the bound control and the application remain highly responsive. Currently, this mode is supported by the DevExpress.XtraGrid.GridControl and DevExpress.XtraEditors.SearchLookUpEdit controls.

A data source supporting Instant Feedback mode must either implement the DevExpress.Data.Async.IAsyncListServer interface or implement the System.ComponentModel.IListSource interface and return an IAsyncListServer instance via the IListSource.GetList method. The XPInstantFeedbackSource component implements the IListSource interface, and returns the list implementing the IAsyncListServer interface via the IListSource.GetList method.

The XPInstantFeedbackSource object serves as a conduit of information between the control and a target data store. When the control needs to display a specific portion of data, it calls a specific method of the bound XPInstantFeedbackSource object. This method sends a corresponding request to the data store, and while receiving the results, immediately passes them back to the control.

When creating an XPInstantFeedbackSource object, you need to provide descriptive information on the target data table (view) in the target data store. Declare a persistent class (an XPBaseObject descendant) that will correspond to the data table (see Basics of Creating Persistent Objects for Existing Data Tables). Then, pass the persistent class type to the XPInstantFeedbackSource constructor. You can use the ObjectType property, to choose the required persistent class at design time. In Instant Feedback mode, the target data table must contain a single key field, and the persistent class must contain a public property corresponding to the table key. If the data table does not contain a key field or the key is composed of several columns, it cannot be used as a data source.

NoteNote

The XPInstantFeedbackSource is a read-only data source. To enable data editing in server mode, use the XPServerCollectionSource with the XPServerCollectionSource.AllowEdit property set to true.
The XPInstantFeedbackSource can only work with thread-safe properties. Reference properties are not thread safe. So, you should not use reference property descriptors when specifying DisplayableProperties.
Assign the DefaultSorting, DisplayableProperties, FixedFilterCriteria, FixedFilterString, and ObjectType properties before binding the XPInstantFeedbackSource to the GridControl or SearchLookUpEdit. Once bound, changing any of these properties throws an exception.

For additional information on Instant Feedback mode, refer to Instant Feedback Mode.

Examples

This example demonstrates how to initialize a XPInstantFeedbackSource, to retrieve data from a "Person.Contact" data table (included in the AdventureWorks database shipped with MS SQL Server). The Person_Contact persistent class is declared, and mapped to the "Person.Contact" data table, using the PersistentAttribute attribute. Then, this class is used as a parameter in the XPInstantFeedbackSource constructor.

using DevExpress.Xpo;
using DevExpress.Xpo.DB;
using DevExpress.Data.Filtering;

// The persistent class describing the "Person.Contact" table 
// from the AdventureWorks SQL database
[Persistent("Person.Contact")]
public class Person_Contact : XPLiteObject {        
    [Key]
    public System.Int32 ContactID;
    public string FirstName;
    public string LastName;
    //...
}
public partial class Form1 : Form {
    //...
    public Form1() {
        // ...
        // Create a filter that selects records where last names start with 'A'     
        CriteriaOperator criteria = CriteriaOperator.Parse("[LastName] LIKE ?", "A%");
        // Specify the properties that will be available for binding
        string displayableProperties = "FirstName;LastName";    
        // Initialize an XPInstantFeedbackSource data source 
        // supplying data from the Person.Contact data table     
        XPInstantFeedbackSource instantDS = new XPInstantFeedbackSource(
            typeof(Person_Contact), displayableProperties, criteria);
        // Handle the ResolveSession event, 
        // to provide a Session to the XPInstantFeedbackSource
        instantDS.ResolveSession += instantDS_ResolveSession;
        // Handle the DismissSession event, to dispose of the Session
        instantDS.DismissSession += instantDS_DismissSession;
        //...
    }
    void instantDS_ResolveSession(object sender, ResolveSessionEventArgs e) {
        Session session = new Session();
        session.ConnectionString = @"Integrated Security=SSPI;Pooling=false;
            Data Source=.\SQLEXPRESS;Initial Catalog=MyDatabase";
        session.Connect();
        e.Session = session;
    }
    void instantDS_DismissSession(object sender, ResolveSessionEventArgs e) {
        IDisposable session = e.Session as IDisposable;
        if(session != null) {
            session.Dispose();
        }
    }
}


 

XPInstantFeedbackSource 类,对gridview简单来说就是:在页面你浏览了多少行,就只能操作多少行数据。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值