Monday, August 30, 2010

Controlling DevExpress XtraGrid Part-3 (The Columns)

Continuning the Controlling XtraGrid Control series..
Contolling DevExpress XtraGrid Part-2 (Master Detail)
Controlling DevExpress AspxGridControl at runtime
Controlling DevExpress XtraGrid Control at runtime

With the great help of DevExpress Support Guys eXpand now has an engine that can push any class property to your model and then using the power of modeldifference module allow you to change its value at runtime.

See for example how simple we have define all the the options of a GridColumn and push them to the model

public interface IModelColumnOptions : IModelColumnOptionsBase {

    IModelGridColumnOptions GridColumnOptions { get; set; }

}

 

public interface IModelGridColumnOptions : IModelNode {

    IModelGridColumnOptionsColumn OptionsColumn { get; set; }

    IModelGridColumnOptionsColumnFilter OptionsFilter { get; set; }

}

 

public interface IModelGridColumnOptionsColumn : IModelNode {

}

 

public interface IModelGridColumnOptionsColumnFilter : IModelNode {

}

 

public class GridColumnOptionsController : ColumnOptionsController<GridColumn, IModelGridColumnOptions>

{

    protected override Func<PropertyInfo, bool> ControlPropertiesFilterPredicate() {

        return info => info.PropertyType == typeof(OptionsColumnFilter) || info.PropertyType == typeof(OptionsColumn);

    }

 

    public override Func<PropertyInfo, bool> DynamicPropertiesFilterPredicate() {

        return info => true;

    }

}

as you can see all above interfaces have no members and are here just to serve their name all the work is done by the base ColumnOptionsController that takes as a generic argument the class we are interested in pushing to the model and provides methods (ControlPropertiesFilterPredicate) to allow us to control the properties that are going to be pushed

image

same process exactly for AspxGridView columns

public interface IModelColumnOptions : IModelColumnOptionsBase

{

    IModelGridColumnOptions GridColumnOptions { get; set; }

}

 

public interface IModelGridColumnOptions : IModelNode

{

    IModelGridViewColumnSettings Settings { get; set; }

}

 

public interface IModelGridViewColumnSettings:IModelNode {

}

 

public class GridColumnOptionsController : ColumnOptionsController<GridViewColumn, IModelGridColumnOptions>

{

    protected override Func<PropertyInfo, bool> ControlPropertiesFilterPredicate() {

        return info => info.PropertyType == typeof(GridViewDataColumnSettings);

    }

 

    public override Func<PropertyInfo, bool> DynamicPropertiesFilterPredicate() {

        return info => true;

    }

}

image

Subscribe to XAF feed
Subscribe to community feed

DiggIt!
blog comments powered by Disqus