This example demonstrates how to customize the appearance of automatically generated map pie charts.
How to customize the appearance of automatically generated map pie charts
How to increase Field Headers height and show caption on two lines
The current version of the XtraPivotGrid control does not fully support word wrap for field headers. Basically, our caption drawing mechanism supports word wrap, but the header height is not increased automatically to show an entire content. However, you can create a simple PivotGridControl descendant and adjust the header height manually. It is only necessary to override the FieldMeasures.CalculateHeaderHeight and FieldMeasures.CalculateDefaultHeaderHeight methods to accomplish this task.
How to automatically create mail-merge documents using the Snap Document Server
This example demonstrates how to use the Snap API to automatically generate master-detail mail merge documents by the DevExpress Document Server.
After running this example, a console application creates a document that is exported to an RTF file located in the application's root folder.
See also: How to provide custom separators for records of a mail-merge document.
How to embed in-place editors into bars
This example shows how to embed in-place editors into a bar using BarEditItem objects. Two editors (DateEdit and SpinEdit) are added with the BarEditItem.EditSettings property. Values for the editors are provided using the EditValue property.
How to highlight a current row in a RichEditControl document (change a background color)
The main idea of this approach is to get a document range that corresponds to the current document row and change a background color of this range.
To get this document range, we use the approach demonstrated in the following example:
How to select a current line in the RichEditControl
Once a corresponding range is obtained, we change character properties of this range in the RichEditControl.SelectionChanged event handler.
How to create BarStaticItem items
This example shows how to create BarStaticItem items, used to display static text within bars.
How to use ASPxUploadControl in a custom Appointment form to upload and save a file content as a custom "byte array" field
How to: Modify the Appointment Editing Form for Working with Custom Fields
To save an uploaded file's content (an array of bytes of the uploaded file and the file name) in an appointment we assign values of the UploadedFile.FileBytes and UploadedFile.FileName properties with the corresponding appointment's custom fields in the ASPxUploadControl.FileUploadComplete event handler.
How to create a ToolbarItemList item
This example shows how to create a ToolbarListItem bar item, used to provide access to available toolbars. The ToolbarListItem object is added to the sub-menu displayed within the main menu.
How to create bars and allow them to be docked at any edge of the window
How to implement multi-row editing in the ASP.NET ListView
The ASPxGridListEditor does not natively support multi-row editing. It is recommended to either use the single-row inline editing by setting the AllowEdit property of the ListView model to True in the Model Editor, or edit objects in a DetailView. The multi-row editing functionality is rarely required, but since our customers usually experience difficulties implementing it, I decided to create this example.
There are several examples on how to implement this functionality in the ASPxGridView without XAF. From my point of view, the How to perform ASPxGridView instant updating using different editors in the DataItem template example is the most appropriate for XAF, because:
- this approach can be easily implemented using runtime code
- we already use DataItem templates to show data in grid cells.
All functionality is implemented in a single controller - the MultiRowEditingController. It performs the following operations:
1. Creates an ASPxCallback control and adds it to a page. This control is used to send callbacks from client-side editors used in grid cells.
2. Replaces the default DataItemTemplate with a custom one (EditItemTemplate). The custom template is required to show editors for the user input in grid cells. This template is based on the DataItemTemplate class used in XAF by default. The only difference is that controls from this template are always in the Edit mode.
3. Assigns the client-side script that performs a callback when the value is changed to the editors added to grid cells via the custom DataItemTemplate. This is done in the editor's Init event handler, because at this moment, the NamingContainer that contains the key of the bound object is available.
4. Handles the callback sent from the client side and changes the value of a corresponding object's property.
I recommend that you review the following help topics for additional information:
Access Grid Control Properties
ASPxGridView.Templates Property
How to use custom ASPxGridView template in a Web XAF application
Important notes
We have not tested this solution under all possible scenarios, so feel free to modify and test the code to better suit your needs. It this approach does not meet your requirements, implement a custom List Editor or ViewItem based on a custom Web user control with the ASPxGridView control configured at design time, as you would do in a standard non-XAF ASP.NET application. Refer to the Simplifying integration of custom controls bound to data from XAF application database blog post for additional information.
See also: ASPxGridListEditor - Support fast data entry in multiple rows
Question Comments
Added By: Yuriy Konytskyy at: 6/3/2013 3:44:39 AM
I doesn't work in v12.2.10
Added By: Anatol (DevExpress Support) at: 7/1/2013 4:19:13 AMI have updated the example. Please see implementation details for version 13.1.
Added By: Sandro Welter (Intelligix) at: 7/5/2013 3:02:00 PMI'm getting the error below.
The error occurred:
Type: NullReferenceException
Message: Object reference not set to an instance of an object.
Data: 0 entries
Stack trace:
The NullReferenceException issue is solved.
Added By: PHN at: 1/30/2014 10:55:55 AMHi,
I have some modifications to support ASPxDateTimePropertyEditor,ASPxLookupPropertyEditor:
using System;
using System.Linq;
using System.ComponentModel;
using System.Web.UI;
using DevExpress.ExpressApp.Web.Editors.ASPx;
using DevExpress.Web.ASPxGridView;
using DevExpress.ExpressApp.Web;
using DevExpress.ExpressApp.Editors;
using DevExpress.Web.ASPxClasses;
using DevExpress.ExpressApp.DC;
using DevExpress.Web.ASPxCallback;
using DevExpress.ExpressApp.Model;
using System.Web.UI.WebControls;
using DevExpress.Web.ASPxEditors;
using DevExpress.Xpo;
using DevExpress.ExpressApp;
namespace WebExample.Module.Web
{
[ListEditor(typeof(object), false)]
public class MultiEditASPxGridListEditor : ASPxGridListEditor
{
const String CallbackArgumentFormat = "function (s, e) {{ {0}.PerformCallback(\"{1}|{2}|\" + {3}); }}"; // ASPxCallback, key, fieldName, value
public MultiRowEditASPxGridListEditor(IModelListView model)
: base(model) { }
ASPxCallback callback;
protected override object CreateControlsCore()
{
Panel panel = new Panel();
callback = new ASPxCallback();
callback.ID = ObjectTypeInfo.Type.Name + "aspxCallback1";
callback.ClientInstanceName = ObjectTypeInfo.Type.Name + "_callback1";
callback.Callback += new CallbackEventHandler(callback_Callback);
panel.Controls.Add(callback);
ASPxGridView grid = (ASPxGridView)base.CreateControlsCore();
grid.HtmlDataCellPrepared += new ASPxGridViewTableDataCellEventHandler(grid_HtmlDataCellPrepared);
panel.Controls.Add(grid);
return panel;
}
void grid_HtmlDataCellPrepared(object sender, ASPxGridViewTableDataCellEventArgs e)
{
if (e.DataColumn is GridViewDataColumnWithInfo && IsColumnSupported(((GridViewDataColumnWithInfo)e.DataColumn).Model))
{
e.Cell.Attributes["onclick"] = RenderHelper.EventCancelBubbleCommand;
}
}
protected override ITemplate CreateDataItemTemplate(IModelColumn columnInfo)
{
if (IsColumnSupported(columnInfo))
{
EditModeDataItemTemplate editModeTemplate = (EditModeDataItemTemplate)CreateDefaultColumnTemplate(columnInfo, this, ViewEditMode.Edit);
editModeTemplate.PropertyEditor.ImmediatePostData = false;
editModeTemplate.CustomCreateCellControl += new EventHandler<DevExpress.ExpressApp.Web.Editors.CustomCreateCellControlEventArgs>(editModeTemplate_CustomCreateCellControl);
return editModeTemplate;
}
else
{
return base.CreateDataItemTemplate(columnInfo);
}
}
void editModeTemplate_CustomCreateCellControl(object sender, DevExpress.ExpressApp.Web.Editors.CustomCreateCellControlEventArgs e)
{
if (e.PropertyEditor.Editor is ASPxWebControl)
{
e.PropertyEditor.Editor.Init += new EventHandler((s, args) => Editor_Init(s, args, e.PropertyEditor.Editor));
}
else if (e.PropertyEditor is ASPxLookupPropertyEditor)
{
ASPxLookupPropertyEditor editor = e.PropertyEditor as ASPxLookupPropertyEditor;
editor.DropDownEdit.DropDown.Init += new EventHandler((s, args) => Editor_Init(s, args, e.PropertyEditor.Editor));
}
}
void Editor_Init(object sender, EventArgs e,WebControl baseEditor)
{
ASPxWebControl editor = (ASPxWebControl)sender;
editor.Init -= new EventHandler((s, args) => Editor_Init(s, args, baseEditor));
// Uncomment to remove editors borders
//editor.Border.BorderStyle = BorderStyle.None;
GridViewDataItemTemplateContainer container = baseEditor.NamingContainer as GridViewDataItemTemplateContainer;
var columnInfo = container.Column as GridViewDataColumnWithInfo;
editor.SetClientSideEventHandler("ValueChanged", String.Format(CallbackArgumentFormat,
callback.ClientInstanceName, container.KeyValue, columnInfo.Model.PropertyName, editor is ASPxDateEdit ? "s.GetText()" : "s.GetValue()"));
}
void callback_Callback(object source, DevExpress.Web.ASPxCallback.CallbackEventArgs e)
{
String[] p = e.Parameter.Split('|');
Object key = TypeDescriptor.GetConverter(ObjectTypeInfo.KeyMember.MemberType).ConvertFromString(p[0]);
IMemberInfo member = ObjectTypeInfo.FindMember(p[1]);
Object value = null;
if (typeof(IXPSimpleObject).IsAssignableFrom(member.MemberType))
{
Type memberKeyType = XafTypesInfo.Instance.FindTypeInfo(member.MemberType).KeyMember.MemberType;
int index1 = p[2].LastIndexOf("(");
int index2 = p[2].LastIndexOf(")");
if (index1 > 0 && index2 > index1)
{
string memberKeyText = p[2].Substring(index1 + 1, index2 - index1 - 1);
value = ObjectSpace.GetObjectByKey(member.MemberType, Convert.ChangeType(memberKeyText, memberKeyType));
}
}
else
{
value = TypeDescriptor.GetConverter(member.MemberType).ConvertFromString(p[2]); ;
}
object obj = ObjectSpace.GetObjectByKey(ObjectTypeInfo.Type, key);
member.SetValue(obj, value);
ObjectSpace.CommitChanges();
}
private Type[] supportedPropertyEditorTypes()
{
return new Type[]{
typeof(ASPxStringPropertyEditor),
typeof(ASPxIntPropertyEditor),
typeof(ASPxBooleanPropertyEditor),
typeof(ASPxEnumPropertyEditor),
typeof(ASPxDateTimePropertyEditor),
typeof(ASPxLookupPropertyEditor)
};
}
protected virtual bool IsColumnSupported(IModelColumn model)
{
if (model.GroupIndex >= 0)
{
return false;
}
foreach (Type type in supportedPropertyEditorTypes())
{
if (type.IsAssignableFrom(model.PropertyEditorType))
{
return true;
}
}
return false;
}
// Sorting and grouping are not supported
protected override ColumnWrapper AddColumnCore(IModelColumn columnInfo)
{
ASPxGridViewColumnWrapper columnWrapper = (ASPxGridViewColumnWrapper)base.AddColumnCore(columnInfo);
if (IsColumnSupported(columnWrapper.Column.Model))
{
columnWrapper.Column.Settings.AllowSort = DevExpress.Utils.DefaultBoolean.False;
columnWrapper.Column.Settings.AllowGroup = DevExpress.Utils.DefaultBoolean.False;
}
return columnWrapper;
}
}
}
Thank you for sharing your code. It looks good. I hope it will be useful for others.
Added By: Apostolis Bekiaris (DevExpress) at: 2/17/2014 7:12:23 AMAdded in eXpandFramework 13.2.7.4
Added By: HEUNGGI LEE at: 6/4/2014 6:10:47 AMHi,
Is it possible to set width length on each column in GridView? It is ugly...especially Character field grid width is too narrow ..
Hi PHN,
I tried with your code but list grid view does not show correctly row items. Last row has same pointer with before last row item.
Hi,
this code does not work in 14.2.....
Thank you for your report. It is necessary to turn on Data Item Templates in MultiEditASPxGridListEditor using the UseASPxGridViewDataSpecificColumns property, since they are disabled in version 14.2 by default. I have updated the example.
Added By: Anatol (DevExpress Support) at: 2/3/2015 8:50:08 AM I have found that this quick fix was insufficient to make this example work correctly in version 14.2. I have replaced it with another fix. A new version is already available.How to use several templates for automatically generated map custom elements
For this, specify the ContentTemplateSelector property of the MapCustomElementSettings object assigned to the ListSourceDataAdapter.ItemSettings property.
How to bind ASPxGridView to an ObjectDataSource with EnablePaging
The example demonstrates how to create ObjectDataSource with select parameters to allow ASPxGridView to perform paging and sorting using SQL queries to a database server. It is possible to enable server-side paging using the ASPxGridView.DataSourceForceStandardPaging property.
See also:
A possible implementation of IListServer interface to achieve Server Mode functionality
OBSOLETE: A possible implementation of IListServer interface to achieve Server Mode functionality in the GridView extension
How to customize the appearance and behavior of automatically generated map custom elements
This example demonstrates how to customize the appearance and behavior of automatically generated map custom elements.
The MapCustomElementSettings class allows specifying parameters of the adapter generated map custom elements.
For this, assign a MapCustomElementSettings object to the ListSourceDataAdapter.ItemSettings property, and customize one or several of the following properties.
- Template - allows specifying the appearance and behavior of generated custom elements.
- ContentTemplate - allows specifying the appearance of data displayed in custom elements.
- ContentTemplateSelector - allows specifying the selector that chooses a template depending on data properties.
How to manually add map bubble charts to a map
Note that bubble sizes do not depending on the MapBubble.Value property values.
How to apply conditional formatting to a range of cells
This example illustrates how to get started with conditional formatting that can be applied to cells that match a certain condition specified by a conditional formatting rule.
In particular, this sample demonstrates how to use the SpreadsheetControl API to create the following types of conditional formatting rules:
- a rule that formats cells whose values are above or below the average;
- a rule that highlights cells whose values are between or not between two specified values;
- a rule that formats top or bottom ranked values;
- a rule that highlights cells containing the given text;
- a rule that formats unique or duplicate values, blank cells and formula errors;
- a rule that highlights cells containing dates in the specified time period;
- a rule that formats cells whose values meet the condition expressed by the relational operator;
- a rule that uses a formula to determine which cells to format;
- a two-color scale conditional formatting rule;
- a three-color scale conditional formatting rule;
- a data bar conditional formatting rule;
- an icon set conditional formatting rule.
- Apply conditional formatting to a complex range
How to preserve the expanded state of TreeList nodes when refreshing data
The example contains a helper class that can be used to save and load the current expanded / collapsed state of the XtraTreeList nodes. Please refer to How to preserve the expanded state of TreeList nodes when refreshing data article to learn more.
Question Comments
Added By: Peppomuck at: 7/14/2013 8:09:46 AM
Why don't you save the node.Id's in a List<int> ?
That would be more type safe (instead of seraching by node.GetValue(node.TreeList.KeyFieldName) and safing object types in ArrayList)
Besides, your example doesn't match when you reassign (e.g. after saving and reloading data) the binding source or the KeyFieldName doesn't expect like in the example.
Is there a chance of this being implemented to the XtraTreeList Suite? I can imagine there are large amounts of people who use this code regularly.
Added By: Olejka (DevExpress Support) at: 2/26/2015 4:29:09 AMHello,
Currently, we don't have plans to implement this option out of the box. We've implemented this solution to allow our users to manually save nodes' state.
Nevertheless, thank you for your input. We will consider implementation of this feature in the future.
How to integrate Snap reports in XAF WinForms
Scenario:
This example demonstrates one possible way of integrating Snap reports in an XAF WinForms application. It contains the Snap module (the SnapModule class library) implementing this functionality and the SnapExampleXpo and SnapExampleEF projects demonstrating how to use this module with XPO and EF.
The example integration shows how to store reports layout in business objects and show a list of these objects, as this is done in the built-in Reports module. The main tool for working with these reports is a custom Snap designer form. Underlying business objects can be configured using custom buttons from this form. It is also possible to show a read-only preview form using corresponding actions.
Note that the Snap module from this example is not a part of the standard XAF delivery and is not tested as intensively as our built-in modules. Feel free to modify and test it further according to your business requirements.
If your clients require other scenarios of integrating the Snap reports, please describe them here or in the Create a Snap Report Module for XAF ticket. Thank you in advance!
Steps to implement:
The Snap module contains a custom SnapDesigner form and classes used to integrate this form in an XAF application - business classes for storing reports and controllers used to show the designer and preview forms. To learn more about integrating custom forms and controls, refer to the Using a Custom Control that is not Integrated by Default topic.
To see how the module works, download the example and launch the SnapExample.Win or SnapExampleEF.Win project. To create a new Snap document, navigate to the Reports navigation item and click New. A Snap designer will be opened (see the screenshot above). It contains several custom commands implemented especially for XAF:
New - creates a new Snap document;
Save - saves changes to the database. If the report is new, shows a DetailView allowing to define document's properties;
Add XAF Data Source - shows a DetailView allowing to define a new data source. Adds this data source to the current Snap document;
Edit Object - opens a DetailView of the current IDocumentData object that stores report's settings in the database. Use this button to remove or change the existing XAF data sources or other report's properties.
To see information about built-in Snap designer's commands and learn more about Snap reports, refer to Snap documentation.
To use the Snap module from this example in your application, perform the following steps:
1. Download the example and build it with your version of our components.
2. Copy the DocumentData and DocumentDataSource classes from the example to your application's business classes module (YourSolutionName.Module). If you are using EF, copy classes from the SnapExampleEF\BusinessObjects folder. If you are using XPO, copy classes from the SnapExample.Module\BusinessObjects folder.
3. Add a reference to the SnapModule assembly to your project (YourSolutionName.Win).
4. Add SnapModule to your application's Modules list. To do this, either open the WinApplication.cs file of the YourSolutionName.Win project and add a SnapModule instance to the Modules collection in a constructor, or add the SnapModule project to your VS solution and drag & drop the Snap module from a toolbox in the Application Designer.
5. Set SnapModule's DocumentDataType property to the DocumentData type you have created in step 2.
ListBox - Moving items between ListBoxes
ASPxGridView - Batch Edit - How to calculate unbound column and total summary values on the fly
This example illustrates how to calculate unbound column and total summary values on the fly. It combines the following two examples: ASPxGridView - How to update total summaries on the client side in Batch Edit mode and ASPxGridView - Batch Edit - How to calculate values on the fly.
ASP.NET MVC Example:
GridView - Batch Edit - How to calculate unbound column and total summary values on the fly
Question Comments
Added By: HASNAIN AHMAD at: 2/26/2015 11:06:44 PM
Respected sir/madam
When copy/paste the code in my VS 2013, it shows an error, "The name 'GetSummaryValue' does not exist in the current context".
Please guide for this problem.
Your truly
Thanks and regards
Hasnain Ahmad
Added By: Sergi (DevExpress Support) at: 2/26/2015 11:11:49 PMHello,
To process your recent post more efficiently, I created a separate ticket on your behalf: T213835: The name 'GetSummaryValue' does not exist in the current context" error when using the code from T116925 code example. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.
How to change the Today date for the DateEdit.
This example demonstrates how to create a DateEdit descendant for setting a custom Today value via events.