Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all 7205 articles
Browse latest View live

Table API - How to create a multiplication table in code

$
0
0

This example illustrates the use of RichEdit Table API to create, fill with values and format a simple multiplication table in a document. The resulting document should look like the one in the picture below.


How to implement multi-row editing in the ASP.NET ListView

$
0
0

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.

 

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 AM    

I have updated the example. Please see implementation details for version 13.1.

Added By: Sandro Welter (Intelligix) at: 7/5/2013 3:02:00 PM    

I'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:

Added By: Anatol (DevExpress Support) at: 1/10/2014 8:32:12 AM    

The NullReferenceException issue is solved.

Added By: PHN at: 1/30/2014 10:55:55 AM    

Hi,
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;
        }
    }
}

Added By: Anatol (DevExpress Support) at: 1/31/2014 12:04:45 AM    

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 AM    

Added in eXpandFramework 13.2.7.4

Added By: HEUNGGI LEE at: 6/4/2014 6:10:47 AM    

Hi,
Is it possible to set width length on each column in GridView? It is ugly...especially Character field grid width is too narrow ..

Added By: Anatol (DevExpress Support) at: 6/5/2014 7:42:58 AM    Yes, this is possible - see Adjust column width in listviews on the Web.Added By: HEUNGGI LEE at: 6/18/2014 9:48:18 PM    

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.

Added By: HEUNGGI LEE at: 12/28/2014 2:51:20 AM    

Hi,
this code does not work in 14.2.....

Added By: Anatol (DevExpress Support) at: 12/29/2014 6:10:51 AM    

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 create unbound columns

$
0
0

This example shows how to add an unbound column to the DXGrid control. This column should display the total price, calculated as follows: UnitPrice * UnitsOnOrder.

How to prevent altering the legacy database schema when creating an XAF application

$
0
0

Scenario
This example shows how to prevent altering the legacy database schema when creating an XAF application. Sometimes our customers want to connect their XAF applications to legacy databases, but they often have strong restrictions, which disallow making any changes in the legacy database schema, i.e. adding new tables, new columns. This is bad, because XAF creates the ModuleInfo table to use an application's version for internal purposes. XPO itself can add the XPObjectType table to correctly manage table hierarchies when one persistent object inherits another one. Usually, legacy databases contain plain tables that can be mapped to one persistent object. So, the XPObjectType table is not necessary in such scenarios.
However, one problem still remains: it is the additional ModuleInfo table added by XAF itself. The idea is to move the ModuleInfo and XPObjectType tables into a temporary database.

For this task we introduced a custom IDataStore implementation, which works as a proxy. This proxy receives all the requests from the application's Session objects to a data store, and redirects them to actual XPO data store objects based upon a table name that has been passed.

Steps to implement

1. In YourSolutionName.Module project create a custom IDataStore implementation as shown in the WinWebSolution.Module\XpoDataStoreProxy.xx file;

2. In YourSolutionName.Module project create a custom IXpoDataStoreProvider implementation as shown in the WinWebSolution.Module\XpoDataStoreProxyProvider.xx file;


3.
In YourSolutionName.Module project locate the ModuleBase descendant and modify it as shown in the WinWebSolution.Module\Module.xx file;

4. Define connection strings under the <connectionStrings> element in the configuration files of your WinForms and ASP.NET executable projects as shown in the WinWebSolution.Win\App.config and WinWebSolution.Win\Web.config files.

IMPORTANT NOTES
1. The approach shown here is intended for plain database tables (no inheritance between your persistent objects). If the classes you added violate this requirement, the exception will occur as expected, because it's impossible to perform a query between two different databases by default.
2. One of the limitations is that an object stored in one database cannot refer to an object stored in another database via a persistent property. Besides the fact that a criteria operator based on such a reference property cannot be evaluated, referenced objects are automatically loaded by XPO without involving the IDataStore.SelectData method. So, these queries cannot be redirected. As a solution, you can implement a non-persistent reference property and use the SessionThatPointsToAnotherDatabase.GetObjectByKey method to load a referenced object manually.
3. As an alternative to the demonstrated proxy solution you can consider joining data from several databases into a database view and then mapping persistent classes to that view: How to: Map a Database View to a Persistent Class.

See also:
How to implement XPO data models connected to different databases within a single application
How to: Use both Entity Framework and XPO in a Single Application

How to add charts to bootstrap tabset with the AngularJS approach

$
0
0

DevExtreme charts are not rendered inside an invisible container. You are required to render a chart when a bootstrap tabset tab become active using the render method.

GridView - FindPanel - How to override the default exclude logic

$
0
0
By default, the '-' and '+' signs are special. For example, a string preceded with a dash "-" is excluded from the result set. If you want to override this logic and use these signs not as special symbols but as regular ones, create a custom grid (How to create a GridView descendant class and register it for design-time use) and override the GridView.ConvertGridFilterToDataFilter method. In this example, the '+' and '-' signs are recognized as regular ones (i.e., not as special symbols).

See also:
Find Panel

How to add a CheckBox column which provides to check/uncheck all CheckBoxes in this column

$
0
0
This example demonstrates how to add a CheckBox column which allows you to check/uncheck all CheckBoxes in this column.
To do this, we add a CheckEdit to the current column's header and bind its IsChecked property to the attached property. Then, we subscribe to the GridColumn's Loaded event.
When Loaded is raised, we iterate through all items in the ItemSource and subscribe to its PropertyChanged event. Also, we iterate through all cells in the current column. If the cell value equal true, we increase the total count of true values.
After that, we subscribe to the ItemSource collection's CollectionChanged event. When IsChecked is changed, we iterate through all cells of the column and set its value to the IsChecked value.
When CollectionChanged is raised, we calculate which item was added/deleted and subscribe/unsubscribe to its PropertyChanged event. Then, we calculate to what value CheckEdit must be set.
When PropertyChanged is raised, we increase/decrease the total count of true values and also determine to what value CheckEdi must be set.

How to generate a sequential and user-friendly identifier field within a business class

$
0
0

Scenario

Orders, articles or other business entities often require that you have user-friendly Id or Code fields that end-users can memorize and use during phone conversations. They are usually sequential, but some gaps can be allowed as well (e.g., when an order is deleted). Refer to this StackOverFlow thread for more information on this common scenario, and a possible implementation.

Steps to implement

1. Add a new business class to your platform-agnostic module, and override its OnSaving or AfterConstruction methods depending on your business requirements, as shown in the Solution2.Module\BusinessObjects\Order.xx file;

2. Build your platform-agnostic project and double-click on the Solution2.Module\Module.xx file to invoke the Module Designer;

3. Refer to the Exported Types section within the designer and expand the Referenced Assemblies | DevExpress.Persistent.BaseImpl node;

4. Select and press the space bar on the OidGenerator and ServerPrefix nodes to include these types into the business model of your module:

IMPORTANT NOTES
1. The DistributedIdGeneratorHelper class demonstrated in this solution creates the IDGeneratorTable and ServerPrefix tables to store the information about the last sequential number of a type.
Although this particular solution is simpler to implement and maintain (as it uses built-in XAF classes) than the How to generate and assign a sequential number for a business object within a database transaction, while being a part of a successful saving process (XAF) example, it is pretty safe and should also work in the most typical business scenarios (except for the middle-tier Application Server scenario, because the Session.DataLayer property is not initialized in this case).

2. You can find functional EasyTest scripts for this scenario in the Solution2.Module\FunctionalTests\E4904.ets file.

Question Comments

Added By: Gareth- at: 10/2/2013 5:58:17 AM    

Thanks, works perfectly - I've seeded the ID by manually changing the [Oid] in the IDGeneratorTable, do I need to worry about the [OptimisicLockField] or will this update automatically?

Added By: Dennis (DevExpress Support) at: 10/2/2013 7:10:50 AM    

@Gareth: No, you do not need to care about the OptimisticLockField.

Added By: MohammedFarooq at: 12/2/2013 1:07:31 AM    

Hi,

The code is really helpful but it increments the value of code even if the record is deleted! How can we stop the code to increase its value when a record is deleted?

Added By: MohammedFarooq at: 12/2/2013 1:25:16 AM    

I manage to figure out the solution. I have just added the IsDeleted checking and it worked like a charm!!!

    Protected Overrides Sub OnSaving()
        If (Not IsDeleted) Then
             Me.codeCore = String.Format("N{0:D6}", DistributedIdGeneratorHelper.Generate(Me.Session.DataLayer, Me.GetType().FullName, String.Empty))
        End If
        MyBase.OnSaving()
    End Sub

Added By: Dennis (DevExpress Support) at: 12/2/2013 1:26:50 AM    

@Mohammed: Yes, your solution is correct. I will consider updating this example accordingly. Thanks for your input in this regard.

Added By: rushdan . at: 11/6/2014 12:02:48 AM    

Hallo

I do not understand about explanation. What I know is, after I run the application, then save the data , it will execute Code number automatically.

Is it this example to show how to execute auto increase number ? Thanks

Added By: Dennis (DevExpress Support) at: 11/6/2014 2:00:43 AM    

@Rushdan: With the current implementation, the generation code is executed when the persistent object is being saved (OnSaving). I do not quite understand your last question. The functionality implemented in this example is well-detailed in the description and it can also be seen from simple code.

Added By: Andrew Bingham 2 at: 2/5/2015 12:40:25 AM    

"override its AfterConstruction method, as shown in the Solution2.Module\BusinessObjects\DomainObject1.xx file"

1. I cannot find the DomainObject1 file in the sample
2. The only BusinessObject is Order.cs which does not have an AfterConstruction method
3. What code need to go in AfterConstruction method?
4. What are the advantages / disadvantages compared to E2829?

Added By: Dennis (DevExpress Support) at: 2/5/2015 12:47:04 AM    @Andrew: Thanks for your feedback.
1-3. I've corrected this misprint in the description. 
3. This particular solution is simpler to implement than E2829.

How to specify dashboard parameter values on the client side in the Web Viewer

How to disable selection checkboxes in the ASPxTreeList

$
0
0

This example demonstrates how to disable the selection checkboxes in the ASPxTreeList in the ASPxTreeList.HtmlRowPrepared event handler.

Note: This approach does not work with the Three-state checkbox feature implementation starting with version v2011 vol 1.

Question Comments

Added By: Dina kl at: 2/5/2015 3:20:45 AM    

How can I do that in version 12.2?
Thanks ahead!

Added By: Larry (DevExpress Support) at: 2/5/2015 3:43:21 AM    Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T205379: How to disable selection checkboxes in the ASPxTreeList in version 12.2. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

ASPxGridView - How to bind GridViewDataComboBoxColumn Edit Form editor at runtime

$
0
0

This example illustrates how to provide GridViewDataComboBoxColumn with data and set its properties at runtime.Please note: the ComboBoxProperties.ValueType should be set according to the Data Type Mappings (ADO.NET) table.

Question Comments

Added By: KMirza at: 4/11/2013 2:07:43 PM    

Can I get the code to add/modify row? I want to avoid this message "Data modifications are not allowed in the online example.".

Added By: Marion (DevExpress Support) at: 4/12/2013 1:25:13 AM    

@Mirza
Simply define the datasource Update command and comment the following line:
throw new Exception("Data modifications are not allowed in the online example.");

Added By: Andrew Werner 1 at: 7/31/2013 9:15:42 AM    

Why is it also necessary to include the "Category Name" column in the dsCombo Box and when binding the aspx combo box (as text field)? What if we only want to display the Category ID in the drop down?

Added By: Andrew Werner 1 at: 7/31/2013 10:00:19 AM    

I ended up doing something very similar to this solution, but since I wanted to display the number field in my combobox (not any text or title), i'm using two columns. but the two columns are the same; they are both the number field. except I call one "title" and one "text".

Added By: Marion (DevExpress Support) at: 7/31/2013 11:38:23 PM    

@Andrew,
It is the most popular solution to show a text field in the ASPxComboBox. However, you can show any data you wish.

Added By: Rob Bronstein at: 8/19/2013 6:32:15 PM    

I was expecting to see a list of items in the dropdownedit control ?

Added By: Marion (DevExpress Support) at: 8/19/2013 11:08:23 PM    

@ Rob,
Yes.

Added By: Gregory Lange 1 at: 2/5/2015 8:07:48 AM    

Can this also be used if you are just using the built in grid view defaults for batch editing?  I don't want to have any code on the html side i rather it all be done from the code behind.

Added By: Anthony (DevExpress Support) at: 2/5/2015 11:39:15 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T205642: ASPxGridView - Using E3591 for batch editing. This ticket is currently in our processing queue. Our team will address it soon.

How to edit multiple values in GridView at the same time

$
0
0


This example demonstrates how to provide the capability to an end-user to edit multiple selected cells values at once:

Question Comments

Added By: Gwan jung at: 6/13/2013 6:28:08 PM    

this code worked perfectly except columns filter exist...

Case :
1. column[0] has filter string "mike"
2. row[0][0] ~ row[10][0] has "mike" value
3. multi select row[1][0] ~ row[4][0]
4. click one of this cells again, delete mike

in that case, mulit edit function work strange....

Added By: Keite Tuane Carvalho at: 2/5/2015 10:15:42 AM    

How I can save these records changed in the database?

Added By: Svetlana (DevExpress Support) at: 2/5/2015 12:45:43 PM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T205671: How to save changes from a grid to a data base. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

How to print DevExpress ASP.NET controls via XtraReports

$
0
0

This example illustrates how to print and/or export DevExpress ASP.NET controls by embedding them into an XtraReport.

In this example an ASPxGridView and WebChartControl are added to a report by using DevExpress.XtraReports.UI.PrintableComponentContainer objects.

Question Comments

Added By: Dhaval.Shah at: 11/21/2013 12:58:11 AM    

Hi all,
When I try to open this solution with VS2010 (DevEx 13.1.7), it says project is incompatible with current version of Visual Studio.
Can you please help?
Thanks

Added By: Paul Astro at: 2/5/2015 2:46:59 PM    

When I try to run the Example via the Example Runner, VS2013 Pro opens on my desktop and i have any error message; "Incopatible" "This project is incompatible with the current version of Visual Studio".  I installed the latest Example Runner. ?

Icon Library Explorer

$
0
0

 In this example, you can see all icons that are available in our Icon Library.

To easily find the required image, you can filter them by image size or used collection or group data by columns. In addition, you can use the Search Panel to find an icon by its text. Then, copy the required icon ID from the "Full Icon ID" column and insert it to the IconID property in your project:

[C#]
settings.Items.Add(item=>{item.Text="Home";item.Image.IconID="navigation_home_16x16";});

GridView - How to track ClientLayout with a separate ListBox

$
0
0
This example illustrates how to track and apply ClientLayout using a separate ListBox.
The main implementation details are:
- Handle the GridViewSettings.CustomJSProperties event and store the currently applied client layout via the MVCxGridView.SaveClientLayout method;
- Handle the client-side ASPxClientGridView Init and EndCallback events, and store the currently applied client layout using a separate ListBox;
- Handle the client-side ASPxClientListBox.SelectedIndexChanged event and perform a custom GridView callback via the client-side MVCxClientGridView.PerformCallback method. Pass the selected client layout as a parameter;
- Handle the custom GridView callback via a separate Action method, retrieve the client layout to be applied, and store this value with ViewData;
- Handle the GridViewSettings.BeforeGetCallbackResult event and check if any client layout should be applied. If so, apply it via MVCxGridView.LoadClientLayout.

WebForms Version:
How to save/load the ASPxGridView's ClientLayout Data and choose them from the ASPxListBox

See Also:
T205817: GridView - How to programmatically Save/Load the last ClientLayout within the Session

GridView - How to programmatically Save/Load the last ClientLayout within the Session

$
0
0
This example is based on the T146962: GridView - How to track ClientLayout with a separate ListBox one. It illustrates how to programmatically Save/Load the last ClientLayout within the Session. In real scenarios, it is possible to use a real database (for example, with a client profile data) instead:

[C#]
@Html.DevExpress().GridView(settings=>{...settings.ClientLayout=(s,e)=>{switch(e.LayoutMode){caseClientLayoutMode.Loading://Load Last ClientLayout Via First Loadif(Session["Layout"]!=null){e.LayoutData=Session["Layout"].ToString();}break;caseClientLayoutMode.Saving://Save Last ClientLayout AutomaticallySession["Layout"]=e.LayoutData;break;}};}).Bind(Model).GetHtml()

[VB.NET]
@Html.DevExpress().GridView( _Sub(settings) ... settings.ClientLayout = _Sub(s, e)SelectCase e.LayoutModeCase ClientLayoutMode.Loading'Load Last ClientLayout Via First LoadIf Session("Layout") IsNot NothingThen e.LayoutData = Session("Layout").ToString()EndIfCase ClientLayoutMode.Saving'Save Last ClientLayout Automatically Session("Layout") = e.LayoutDataEndSelectEndSubEndSub).Bind(Model).GetHtml()

Note that the same behavior can be mimic via the GridView's SettingsCookies:

[C#]
@Html.DevExpress().GridView(settings=>{...settings.SettingsCookies.Enabled=true;}).Bind(Model).GetHtml()

[VB.NET]
@Html.DevExpress().GridView( _Sub(settings) ... settings.SettingsCookies.Enabled = TrueEndSub).Bind(Model).GetHtml()

However, in this case, the last ClientLayout is stored within an end-user's browser (i.e., on the client side).

See Also:
T146962: GridView - How to track ClientLayout with a separate ListBox

How to customize mini map behavior and appearance

$
0
0

 This example demonstrates how to customize mini map behavior and appearance.

 

The Mini map supports two behavior types.
- Fixed. The mini map's zoom level and a center point are fixed.
- Dynamic. The mini map's zoom level and a center point are based on the map's zoom level and center point.
To specify the behavior, assign the required behavior class to the MiniMap.Behavior property.

In addition to basic WPF Control properties, the MiniMap class contains the following properties, which allow customizing its appearance: AlignmentViewportTemplate.

OBSOLETE - How to populate ComboBoxEdit with enumeration elements

$
0
0

======================
This article is now obsolete starting from 14.2. Refer to the How to: Use EnumItemsSourceBehavior ticket instead.
======================

To bind ComboBoxEdit to an enum, use the EnumItemsSource markup extention in the following manner:

[XAML]
<dxe:ComboBoxEditItemsSource="{dxe:EnumItemsSource EnumType=local:MyEnum}"/>

For version 13.1 and earlier:
All logic is encapsulated in the BaseComboBoxStyleSettings descendant which is defined in the MyComboBoxStyleSettings.cs(vb) file. The representation of items in the popup window depends on the enumeration items kind. E.g., if enumeration items have description attributes they will display the description text instead of item names. If the enumeration definition is decorated with the FlagsAttribute attribute, items will be represented as check editors with the TextBlock element used as description.

Question Comments

Added By: Marcin Sulecki at: 11/13/2014 5:33:39 AM    

I has just Description attribute to MyEnum but ComboBoxEdit displays item names instead description. I use version 14.1

public enum MyEnum
   {
       [Description("Eating")]
       Eat,

       [Description("Sleeping")]
       Sleep,

       [Description("Coding")]
       Code
   }

I count on your help.

Added By: Ilya (DevExpress Support) at: 11/13/2014 6:52:34 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T173028: How to display description of an enum item when EnumItemsSource is used in ComboBoxEdit. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

How to reorder grid rows by drag and drop

$
0
0

This example extends the example provided in the How to allow an end-user to move the rows in a grid up and down if the grid is bound to a DataTable article with drag and drop functionality.

Question Comments

Added By: Micha Ben-Efraim at: 6/11/2012 2:11:54 AM    

I copied this example for reordering the element of a list bound to the control and it works almost perfectly. The problem is that the control doesn't scroll during D&D: the list is longer as the displayed window. If I select the first or the last item in the list (first/last row) and want o move to the last/first position, which is not visible, the view should scroll somehow in order to show the target drop row. But it doesn't do it when I move the cursor to the top/bottom of the view.
Can it

Added By: Fmonteiro at: 11/5/2013 3:34:26 AM    

Is possible to make this with the AdvBandedGridView?
I've tryed to make the same but in the:
Private Sub GridControl1_DragOver(sender As System.Object, e As System.Windows.Forms.DragEventArgs) Handles GridControl1.DragOver
    ' If e.Data.GetDataPresent(GetType(GridHitInfo))

allways returns False, so never enters the IF.

Added By: softwaresupport@smec.com softwaresupport@smec.com at: 6/4/2014 5:43:37 AM    

Hi created a new ticket for this implementation as i dont find that it works

Added By: softwaresupport@smec.com softwaresupport@smec.com at: 6/4/2014 5:44:03 AM    

Here is the ticket ID : T114366

Added By: Nikita (DevExpress Support) at: 6/4/2014 11:29:33 PM    

Hello,
Ok, let's continue our discussion in this ticket.

Added By: Miles Young at: 2/6/2015 7:34:33 AM    

Hi,

This works fine for me after I changed my "Order" column to decimal in my database.

I'd like to know how to change this value and make sure that RowUpdated() is fired though, like when I edit a row normally.

Thanks for this example.

M.Young

Added By: Svetlana (DevExpress Support) at: 2/6/2015 9:25:03 AM    Hi, 

We are already working on your inquiry in the How to force row update thread you created. We will answer you there. Please do not create duplicate posts. Thank you for your understanding. 

How to programmatically create a chart

$
0
0

This example demonstrates how to create a chart completely via code and add it to a WPF window at runtime.

Question Comments

Added By: KY LABOR at: 2/6/2015 11:02:01 AM    

This is great for WPF, but is there an equivalent WinForm example?

Viewing all 7205 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>