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

How to emulate a TreeList using the master-detail GridView

$
0
0

This example demonstrates how to override the GridView painting mechanism, and draw lines within the master row indent area, to link a master row with detail rows, like the TreeList does for parent node and its children.

Question Comments

Added By: Hannes Schneider at: 2/16/2017 1:42:35 AM    Hi, sorry example does not run with ExampleRunner. And I have included the custom control into my project -> code is executed but grid still looks exactly as a normal grid.... is there any improvement on this?Added By: Svetlana (DevExpress Support) at: 2/16/2017 2:37:55 AM    

Hello,

I've created a separate ticket on your behalf (T483659: E2290 cannot be run). It has been placed in our processing queue and will be answered shortly.


How to export worksheet range to a DataTable without SpreadsheetControl

ASPxImageSlider - How to add different CSS slide effects

$
0
0
This example illustrates how to add CSS3 transformation effects for ASPxImageSlider.

How to dynamically create a read-only calculated (persistent alias) property

$
0
0

When building and extending persistent classes at runtime, it is often desirable to create a non-persistent calculated property. Currently available XPClassInfo.CreateMember method overrides are only capable of creating writable XPCustomMemberInfo instances and the XPCustomMemberInfo.ReadOnly property cannot be changed.

This example demonstrates how to create a custom XPAliasedMemberInfo class inherited directly from XPMemberInfo. In this class constructor, we add PersistentAliasAttribute with a specified expression, and override the GetValue method to evaluate the alias expression in the same manner as it is done in the XPBaseObject class. The read-only behavior is achieved by passing an argument to the base class constructor.

Also, an extender is implemented to provide additional methods for XPClassInfo class.

 

Question Comments

How to: Configure the Way Properties Are Displayed and Edited at the Data Model Level

$
0
0

The DXPropertyGrid supports a large number of attributes from the System.ComponentModel.DataAnnotations library as well DevExpress attributes (see Data Annotation Attributes for more information), and you can use them to control the way properties are displayed.

In this example, we used several attributes including the PropertyGridEditorAttribute, which allows you to specify a particular editor for a property in the PropertyGridControl.

See also:
PropertyGridControl - How to use various editor types based on custom attribute values

PropertyGridControl - How to use various editor types based on custom attribute values

$
0
0

In this example, we dynamically generate the PropertyGridControl.PropertyDefinitionsSource and PropertyDefinitionBase.PropertyDefinitionsSource collections based on the underlying data source objects. To generate proper definitions, we implemented a custom PropertyDefinitionTemplateSelector and select one of the following templates based on the underlying property:
1. CollectionDefinitionTemplate. We use it if the underlying property is a collection.
2. CustomDefinitionTemplate. This template is applied only if a specific attribute is set (in this example, we use a custom CustomEditorAttribute).
3. If the underlying object does not meet the previous conditions, we return DefinitionTemplate.

Finally, there is a custom CellTemplateSelector in CustomDefinitionTemplate. In this selector, we check the CustomEditorAttribute attribute value and return one of predefined templates based on it.

See also:
How to: Configure the Way Properties Are Displayed and Edited at the Data Model Level

TreeListEditor - How to enable in-place editing in the WinForms tree List View (XPO)

$
0
0

This example shows how to implement a custom ViewController that gets access to the TreeList control and makes it editable according to the XtraTreeList documentation:
    WinForms Controls > Controls > Tree List > Feature Center > Data Editing
    TreeListOptionsBehavior.Editable Property
    TreeList.ShowingEditor Event
    TreeList.CellValueChanged Event
Take special note that this is not a complete solution and you will need to modify and test this example code further in other scenarios according to your business requirements. For instance, if you require supporting ConditionalAppearance rules, consider using the code from the Q479878 ticket. If you require supporting member-level security permissions, consider extending this example by analogy with the DevExpress.ExpressApp.Win.SystemModule.GridListEditorMemberLevelSecurityController class for GridListEditor.
Refer to the Tree List Editors - How to edit data directly in the tree view (inplace / inline modifications) thread to learn more about possible limitations and alternative solutions.

 

See also:
How to enable in-place editing in the ASP.NET tree List View (ASPxTreeListEditor)

Question Comments

Added By: Kerry Busby at: 6/21/2012 10:17:49 PM    

Are there any plans on ever incorporating this into the 'official' code base of XAF. The solution below previously could be manipulated with another controller to support EditorStateRule attributes and disable specific property editors however not that the EditorState module has been removed in DXPerience 2012 this is not possible or at least a LOT more difficult with the new Appearance module. There are a number of posts requesting this previously but currently it appears as if TreeLists with inplaced editing will never be 'officially' supported.

Added By: Willem de Vries at: 12/7/2012 3:11:17 AM    

+1 for Kerry!
DX, do not hesitate to upgrade Xpand gems to the XAF code base.
Willem

Added By: David Perfors at: 3/22/2013 6:17:49 AM    

A nice addition to this example is support for ImmediatePostDataAttribute:
[code lang="cs"]
void treeList_CellValueChanging(object sender, CellValueChangedEventArgs e)
        {
            if (ImmediatePostData(e))
            {
                SetValue(e);
            }
        }

        private void treeList_CellValueChanged(object sender, CellValueChangedEventArgs e)
        {
            if (!ImmediatePostData(e))
            {
                SetValue(e);
            }
        }

        private void SetValue(CellValueChangedEventArgs e)
        {
            object newValue = e.Value;
            if (e.Value is IXPSimpleObject)
                newValue = ObjectSpace.GetObject(e.Value);
            object focusedObject = _treeList.FocusedObject;
            if (focusedObject != null)
            {
                IMemberInfo focusedColumnMemberInfo = ObjectSpace.TypesInfo.FindTypeInfo(focusedObject.GetType()).FindMember(e.Column.FieldName);
                if (focusedColumnMemberInfo != null)
                    focusedColumnMemberInfo.SetValue(focusedObject, Convert.ChangeType(newValue, focusedColumnMemberInfo.MemberType));
            }
        }

        private bool ImmediatePostData(CellValueChangedEventArgs e)
        {
            if (_treeList.FocusedObject != null)
            {
                IMemberInfo focusedColumnMemberInfo = ObjectSpace.TypesInfo.FindTypeInfo(_treeList.FocusedObject.GetType()).FindMember(e.Column.FieldName);
                return focusedColumnMemberInfo.FindAttribute<DevExpress.Persistent.Base.ImmediatePostDataAttribute>() != null;
            }
            return false;
        }
[/code]

Added By: kirsten greed at: 12/3/2016 7:12:36 PM    The code references IXPSimpleObject  but this is not definedAdded By: Dennis (DevExpress Support) at: 12/5/2016 8:26:20 AM    

@Kirsten: This XPO-specific interface is defined in the DevExpress.Xpo assembly.
If you are using EF for data access, you can implement the DevExpress.ExpressApp> IXafEntityObject interface by required business objects, which are used in TreeListEditor columns, and then modify the example code to test for this interface instead of IXPSimpleObject. Please let us know if you experience any further difficulties with this task.

Permissions for Aggregated Objects

$
0
0

This example illustrates differences between the Strict and ConsiderOwnerPermissions modes of checking permissions to access aggregated objects.


How to create a ASP.NET MVC Dashboard Designer application with predefined data sources

$
0
0

This example shows how to create an ASP.NET MVC Dashboard Designer application and provide data for dashboards.

The project contains a simple dashboard and two available data sources: the XML and OLAP data sources. You can use these data sources to create a new dashboard. To learn how to create an MVC Designer application from scratch, see the following topic: Creating an ASP.NET MVC Dashboard Designer Application.

Note that the OLAP data source requires the ADOMD.NET data provider installed on the web server. You can get the latest version of this provider here: https://www.microsoft.com/en-us/download/details.aspx?id=42295.

How to create a ASP.NET MVC Dashboard Designer application

How to: display the loading panel for WinForm controls

$
0
0

This example demonstrates how to emulate the loading panel used in ASP.NET applications to indicate the loading process when a control sends a callback.

Question Comments

Added By: YJ0702 at: 3/14/2013 1:27:33 PM    

How can i use 'WaitForm' when child form is loading?
I want to display loading panel when child form is loading... thanks.

Added By: Wiley Siler 1 at: 2/20/2017 7:36:33 AM    How can this be about WinForms if it is for ASP.NET?

How to separate data between employees and managers of different departments using security permissions in XPO

$
0
0

Scenario
This example demonstrates how to use the new security system to implement the following security roles:

- Users (Joe, John) can view and edit tasks from their own department, but cannot delete them or create new ones. They also have readonly access to employees and other data of their own department.

- Managers (Sam, Mary) can fully manage (CRUD) their own department, its employees and tasks. However, they cannot access data from other departments.

- Administrators (Admin) can do everything within the application.
All users have empty passwords by default.


Steps to implement

1.Permissions at the type, object and member level (with a criteria) are configured in the MainDemo.Module/DatabaseUpdate/Updater file. Take special note that for building a complex criteria against associated objects, the ContainsOperator together with the built-in CurrentUserId and IsCurrentUserInRole criteria functions. For greater convenience, strongly typed criteria for permissions are accompanied with their string representation.

2. The SecuredObjectSpaceProvider is used in the CreateDefaultObjectSpaceProvider method of the XafApplication descendants located in the WinForms and ASP.NET projects.

3. Permission requests caching is enabled via the IsGrantedAdapter.Enable method in the MainDemo.Module\MainDemoModule.xx file (see the T241873 ticket for more details).

4. The Department, Employee and EmployeeTask classes are implemented in the MainDemo.Module/BusinessObjects folder. To quickly understand relationships between involved business classes, their class diagram is attached.


IMPORTANT NOTES
1. 
See also the functional tests in the MainDemo.EasyTests folder for more details on the tested scenarios.
2.
For versions older than v15.2.5, be aware of the issue described in the Security - The "Entering state 'GetObjectsNonReenterant'" error may occur while saving data if a permission criteria involves a collection property thread.
3.The State of the New Security System

Question Comments

Added By: Raoulw at: 2/11/2013 2:02:04 PM    

This is a great sample. There is one error, or it is not clear in the description. 'Users (Joe, John) can do everything with their own tasks and can also view data of their own department;' implies that Joe has read only access to Mary's tasks, which is not true. The code below fixes that.

Raoul.

                SecuritySystemObjectPermissionsObject canSeeTasksOnlyFromOwnDepartmentObjectPermission = ObjectSpace.CreateObject<SecuritySystemObjectPermissionsObject>();
                //canSeeTasksOnlyFromOwnDepartmentObjectPermission.Criteria = "AssignedTo.Department.Oid=[<Employee>][Oid=CurrentUserId()].Single(Department.Oid)";
                canSeeTasksOnlyFromOwnDepartmentObjectPermission.Criteria = new BinaryOperator(new OperandProperty("AssignedTo.Department.Oid"), joinEmployees, BinaryOperatorType.Equal).ToString();
                canSeeTasksOnlyFromOwnDepartmentObjectPermission.AllowNavigate = true;
                canSeeTasksOnlyFromOwnDepartmentObjectPermission.AllowRead = true;
                canSeeTasksOnlyFromOwnDepartmentObjectPermission.AllowWrite = false;
                canSeeTasksOnlyFromOwnDepartmentObjectPermission.AllowDelete = false;
                canSeeTasksOnlyFromOwnDepartmentObjectPermission.Save();
                employeeTaskPermissions.ObjectPermissions.Add(canSeeTasksOnlyFromOwnDepartmentObjectPermission);

Added By: Dennis (DevExpress Support) at: 7/4/2013 7:31:27 AM    

Thanks for your update, Raoul!

Added By: Konstantin B at: 10/17/2013 4:47:01 AM    

I'm tried to apply solution for bug fixing "Security - The "Entering state 'GetObjectsNonReenterant error may occur while saving data if a permission criteria involves a collection property" to this example, but unsuccessfully - always get GetObjectsNonReenterant exception.
Could you please supply the project how can fix it for the current example?

Thanks

Added By: Dennis (DevExpress Support) at: 10/21/2013 6:32:14 AM    

Please track https://www.devexpress.com/Support/Center/Question/Details/Q287727 for any updates on this problem. Thanks!

ASPxGridView - How to hide the detail button if the detail grid is empty

$
0
0

This example illustrates how to hide the detail button for "empty" detail rows using the server-side DetailRowGetButtonVisibility event

Question Comments

Added By: Luis Rodriguez 15 at: 10/6/2015 12:54:32 PM    

how could I use with sqldatasource?

Added By: Sergi (DevExpress Support) at: 10/6/2015 11:20:15 PM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T297564: ASPxGridView - How to hide the detail button if the detail grid is empty when using SqlDataSource. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Sree Chitoor at: 2/20/2017 11:37:44 PM    Hi Team,

Thanks for quick your response but our scenario is totally different.

In our scenario, we're binding the grid dynamically which is using ITemplate.

For your reference here I added code block.

[VB.NET]
PublicClass SecondLevelDetailTemplateImplements ITemplatePublicSub InstantiateIn(container As Control) Implements ITemplate.InstantiateInIf HttpContext.Current.Session("dsEpic") IsNot NothingThenDim con As GridViewDetailRowTemplateContainer = TryCast(container, GridViewDetailRowTemplateContainer)Dim grid AsNew ASPxGridView()DimkeyAsString = con.KeyValue.ToString() grid.ID = con.KeyValue.ToString() container.Controls.Add(grid) grid.KeyFieldName = "WPATTKeyColumn" grid.AutoGenerateColumns = True grid.Width = Unit.Percentage(100)Dim btnColun AsNew GridViewCommandColumn() grid.Columns.Add(btnColun) btnColun.VisibleIndex = 5 btnColun.Caption = "View" grid.Settings.ShowColumnHeaders = TrueDim cmd AsNew GridViewCommandColumnCustomButton() cmd.Image.Url = "Images/icpdf.gif" btnColun.CustomButtons.Add(cmd)AddHandler grid.CustomButtonCallback, AddressOf grid_CustomButtonCallbackAddHandler grid.CustomButtonInitialize, AddressOf grid_CustomButtonInitDim col1, col2, col3, col4, col5, col6, col7, col8 As GridViewDataTextColumn col1 = New GridViewDataTextColumn() col1.FieldName = "NUMBER" col1.Caption = "Number" col1.VisibleIndex = 0'col1.Width = getWidth("180") grid.Columns.Add(col1) col2 = New GridViewDataTextColumn() col2.FieldName = "CleanCommentColumn" col2.Caption = "Title" col2.VisibleIndex = 1 grid.Columns.Add(col2) col3 = New GridViewDataTextColumn() col3.FieldName = "VERSION" col3.Caption = "Version" col3.VisibleIndex = 2 grid.Columns.Add(col3) col4 = New GridViewDataTextColumn() col4.FieldName = "EFFECTIVE_DATE" col4.Caption = "Effective Date" col4.VisibleIndex = 3 grid.Columns.Add(col4) col5 = New GridViewDataTextColumn() col5.FieldName = "FilePath" col5.VisibleIndex = 6 col5.Visible = False grid.Columns.Add(col5) col6 = New GridViewDataTextColumn() col6.FieldName = "FILENAME" col6.VisibleIndex = 7 col6.Visible = False grid.Columns.Add(col6) col7 = New GridViewDataTextColumn() col7.FieldName = "DocType" col7.FieldName = "Unit"' Fixed for demo comments on feb17-2017 col7.VisibleIndex = 4 grid.Columns.Add(col7)Dim dsEpic As DataSet = CType(HttpContext.Current.Session("dsEpic"), DataSet)TryDim rowList As DataRow() = dsEpic.Tables(2).Select(String.Format("WPKeyColumn ='{0}'", key))If 0 < rowList.Count ThenDim dtTable As DataTable = New DataTable() dtTable.Columns.Add("NUMBER") dtTable.Columns.Add("VERSION") dtTable.Columns.Add("FILENAME") dtTable.Columns.Add("EFFECTIVE_DATE") dtTable.Columns.Add("CleanCommentColumn") dtTable.Columns.Add("FilePath") dtTable.Columns.Add("Unit")Dim row As DataRowFor i = 0 To rowList.Count - 1Dim duplicatePRC AsString = String.Empty row = dtTable.NewRow() If duplicatePRC = rowList(i).ItemArray(19).ToString() ThenContinueForEndIfDim title AsString = rowList(i).ItemArray(7).ToString()Dim comments AsString = rowList(i).ItemArray(11).ToString()If (NotString.IsNullOrWhiteSpace(comments)) Then title += " " + """" + comments + """"EndIfDim effDate AsString = ConvertYearFormat(rowList(i).ItemArray(12).ToString()) row(0) = rowList(i).ItemArray(19) row(1) = rowList(i).ItemArray(5) row(2) = rowList(i).ItemArray(8) row(3) = effDate row(4) = title row(5) = rowList(i).ItemArray(27) row(6) = rowList(i).ItemArray(18) 'Demo purpose added on feb 17 2017 dtTable.Rows.Add(row)Next grid.DataSource = dtTable EndIfCatch ex As Exception System.Diagnostics.Debug.WriteLine(ex.Message & " Key is"& key)EndTryEndIfEndSubEndClass

Thanks in Advance,
Sree

How to: Build a Layout of Controls within LayoutPanels

$
0
0

This example shows how to arrange controls within LayoutPanels forming a custom layout.

Synchronization with MS Outlook - a demonstration example

$
0
0
This example allows you to examine the operation of AppointmentExportSynchronizer and AppointmentImportSynchronizer objects which enable you to implement your own synchronization method.
WARNING: When you run this example, you can delete all data in your MS Outlook calendar. We suggest that you backup your data prior to running the example.
Question Comments

Added By: Alexander Koshmelev at: 11/30/2015 10:19:10 PM    

Hello!
Dear devExpress team,
please provide a complete sample of Synchronization with MS Outlook!
Best Regards, Alex

Added By: George (DevExpress Support) at: 11/30/2015 11:08:06 PM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T318784: Provide a complete sample of synchronization with MS Outlook. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Tom Gibson 3 at: 12/24/2015 8:02:20 AM    

When I try this example, all my outlook appointments are deleted.  Also if I add an appointment in outlook then synchronise, all my resource items get the appointment.  How can I only Synchronise my Appointments, and not delete existing ones.

Added By: Andrey (DevExpress Support) at: 12/24/2015 8:18:44 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T328346: Outlook appointments are deleted when the T158895 example is used to synchronize the Scheduler control with MS Outlook. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Kathleen Jordan at: 2/21/2017 7:51:18 AM    DevEx - you really need to put a warning in the program code itself - I've just run this example and lost absolutely everything from my Outlook diary - business appointments, personal appointments, birthdays, recurring appointments, everything.  I'll be able to get some stuff back from backups but recent stuff is lost forever.  Putting a line at the top of the page in the same font and colour is hardly a useful warning for such a dangerous task - from the description, I thought I was going to be copying a single test record over to Outlook, not deleting everything!  Can't understand why you think having this dangerous piece of code on a support page is acceptable. 

How to create Data Access Library data sources at runtime

GridView - How to Select a Particular Row when a Page is Opened First Time

$
0
0

This example demonstrates how to select a particular rows when a page is opened first time

How to show a hyper link (URL, email, etc.) for a business class property

$
0
0

Scenario
The following basic functionality is implemented in the HyperLinkPropertyEditor.Web and HyperLinkPropertyEditor.Win modules:

1. Custom PropertyEditor classes for WinForms and ASP.NET based on the HyperLinkEdit and ASPxHyperLink controls that can be used for representing object fields, containing email address or a URL in the UI.
2. To validate an input, a combined RexEx mask is used in both ListView and DetailView of Windows Forms and ASP.NET applications. The default regular expression is the following:
(((http|https|ftp)\://)?[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&amp;amp;%\$#\=~])*)|([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6})
You can use it as is or modify it per your specific needs. Look for Regular Expressions in MSDN for more information on how to do this.
3. The default email client or default browser window is opened after a single click on the hyperlink if it represents a valid email or web address. For end-users convenience, in DetailView of Windows Forms projects, a double-click is necessary to be able to easily edit the field.



Steps to implement

1. Copy and include the HyperLinkPropertyEditor.Web and HyperLinkPropertyEditor.Win projects into your solution and make sure it is built successfully. Feel free to modify the settings of the underlying controls according to their documentation to better meet your business needs, e.g. provide a custom display text instead of the raw URL via the RepositoryItemHyperLinkEdit.Caption and ASPxHyperLink.Text options.

2. Invoke the Application Designer for the YourSolutionName/WinApplication.xx file by double-clicking it in Solution Explorer. Invoke the Toolbox (Alt+X+T) and then drag & drop the HyperLinkPropertyEditorWindowsFormsModule component into the modules list on the left.

3. Invoke the Application Designer for the YourSolutionName/WebApplication.xx file by double-clicking it in Solution Explorer. Invoke the Toolbox (Alt+X+T) and then drag & drop the HyperLinkPropertyEditorAspNetModule component into the modules list on the left.
4. Define a string persistent property within your business class and decorate it with the DevExpress.Persistent.Base.EditorAliasAttribute passing the "HyperLinkStringPropertyEditor" string as a parameter. See the E2096.Module\HyperLinkDemoObject.xx file for an example.


Frequently Asked Questions
E2096 - How to specify a display text for the hyper link based on a different business class property

How to customize a column's context menu (add/remove menu items)

$
0
0

The following example demonstrates how to customize a column's context menu. In this example, the default 'Show Column Chooser' menu item is removed from a column's Context Menu, and a custom item is instead.

Question Comments

Added By: Kaela at: 2/23/2017 9:17:51 AM    How can I add a custom bar button item using a style so that I can reference the same resource dictionary from all of our forms with grids?

Thank you,

Kaela

How to access the information on the master detail view from the controller for nested list view.

$
0
0

This example shows how retrieve master detail view information from the controller for the nested list view. In particular, here we need to know the ID of the parent detail view to adjust our logic in the controller respectively.
There are MasterDetailViewControllerBase and NestedListViewControllerBase controllers that allow you to achieve this task. Your should inherit your controllers for nested list views from the last base controller, if you want to have a MasterDetailViewId for them.
In this instance, the MasterDetailViewControllerBase will provide the required parent view ID for it.

See Also:

How to: Access the Master Object from the Nested List View
Platform Independent way to determine Parent DetailView
FAQ: How to traverse and customize XAF View items and their underlying controls (describes an alternative approach with a Controller for the master DetailView that accesses its nested ListPropertyEditor)

Viewing all 7205 articles
Browse latest View live


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