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

ASPxGridView - How to apply a filter to a column on the server side


How to implement a custom XPO Membership Provider

$
0
0

The example is based on a couple of articles regarding custom Membership and Roles provider implementation using the XPO framework. The XPO framework has a great advantage, allowing you to store objects in different databases. The example demonstrates some basic implementation of a custom membership provider. There are some known issues with the example, and we plan to improve it in future.

Each version of the example will have some description about its main features, or known limitations.

See also:
Forum: XpoMembershipProvider Implemented
MSDN: Introduction to Membership
MSDN: Sample Membership Provider Implementation

Example Comments

Added By: Alejandro Charbonnier at: 7/16/2013 1:35:15 PM    

How can I know what changed in this example?

How to replace the cursor with a thumbnail image while dragging a row in GridView

$
0
0

This example demonstrates how to replace the standard cursor with a transparent image of the dragged row during a drag-and-drop operation in GridView

Example Comments

Added By: Rennie Petersen at: 3/28/2013 12:24:50 AM    

I haven't tested it myself, but I'm wondering if this DragImageHelper class doesn't have a resource leak problem. See the comments on this article:
http://tech.pro/tutorial/732/csharp-tutorial-how-to-use-custom-cursors

On the other hand, the proposed fix seems a bit kludgy - it presumably makes it impossible to have more than one custom cursor in effect at the same time.

How to display different images when an end user switches the Large Icons option within the Bars customization form

How to display custom text next to a check box within the same cell

How to use DXGrid in Server Mode with Entity Framework 4.0+

Binding Master and Detail focused rows to ViewModel objects

$
0
0

This example demonstrates how to use ViewModel properties to track and control focused row changes both for Master and Detail grids. This capability is achieved by creating attached behavior that handles all necessary events (especially for the focused view and row changing, both in the detail and master grids). The logic of focusing rows can be changed inside this behavior depending on your requirements. For example, you may want not to focus the first detail row when a master row is expanded. If so, change the MasterRowExpanded event handler as follows:

[C#]
voidMasterGridMasterRowExpanded(objectsender,RowEventArgse){(MasterGrid.GetDetail(MasterView.FocusedRowHandle)asGridControl).View.FocusedRow=null;}

So, the main idea of the example is to show how the row focusing logic can be defined in the GridControl that operates in Master-Detail mode.
Note that the approach shown in the example will work only with the DataControlDetailDescriptor, as other descriptors use custom templates to display detail content that is not synchronized with the master grid. In addition, the created behavior will not work in the multi-level Master-Detail hierarchy.

Example Comments

Added By: Manar Husrieh at: 12/24/2012 7:50:04 AM    

Hi,
I have tried to implement the example but I have a problem. When I am using master grid with multiple details using TabViewDetailDescriptor, The parent is not a master grid. I have checked it and its type is TabViewDetailDescriptor and its parent is always null. This problem is in the DetailFocusedRowBehavior in the MasterView property.
Regards,
Manar Husrieh

Added By: Volodymyr Fedishov at: 12/27/2012 12:12:49 PM    

Unfortunately this example has a serious issue. You can see the problem if you'll do the following:
1) Expand first master row (Bruce). In result we see that in ViewModel FocusedEmployee=Bruce and FocusedOrder=Supplier 1 - TV.
2) Expand second master row (Cindy). In result we see that in ViewModel FocusedEmployee=Cindy and FocusedOrder=Supplier 1 - Blue-Ray Player.
3) Now select Suplier 1 - TV detail row under Bruce master row again. And what we see? In ViewModel FocusedOrder=Supplier 1 - TV, but the FucusedEmployee=Cindy. Obviously I expected to see Bruce selected.
But it's not obvious how to change this example to make it work this way. Can you show how to change this example to automatically focus the parent master row when detail row gets selected?

Added By: Alexander Ch (DevExpress Support) at: 1/11/2013 4:06:38 AM    

Hello guys,
I apologize for the delay in our response. Usually, we do not review comments to examples, so, in the future, I suggest you create a support ticket regarding problems you face.
As for your questions:
Manar, I'm afraid it is not possible to use TabViewDetailDescriptor with the demonstrated behavior. It supports DataControlDetailDescriptor only.
Volodymyr, thank you for reporting this issue. This behavior is definitely incorrect. I have fixed it and updated the example.

SpreadsheetControl API Part 02

$
0
0

This example demonstrates how to use the SpreadsheetControl API to programmatically manage spreadsheet documents.

This sample introduces API properties and methods used to perform the following operations:
- Insert and manage pictures
- Create custom spreadsheet functions



How to Create a Custom Column Chooser

$
0
0

This example shows how to create a custom standalone Column Chooser, and display it within the Expander control.

How to create a Master-Detail report

$
0
0

This example shows how the MailMerge feature enhanced with the DOCVARIABLE field specifics with the help of the RichEditDocumentServer text processing engine empowers the users to accomplish complex reporting tasks, such as creating Master-Detail reports.
The project uses a three-level Supplier-Product-OrderDetail hierarchical data source with the ITypedList interface, implemented as described in the E137: How to create a hierarchical master-detail datasource example. The XtraGrid GridControll is chosen to preview data because of its support for displaying hierarchical data sources in the most natural manner.

The application screenshot is shown below.

How to add custom menu item to column's filter dropdown list.

$
0
0

This example demonstrates how to add a "(Custom)" menu item to a column's filter dropdown list, which allows showing the Custom AutoFilter window in the same manner as the one used in the WinForm GridControl.

Report Storage for the End-User Report Designer

$
0
0

The following example demonstrates how to implement a report storage to persist report definitions in a database or in any other custom location. This may be useful when providing end-users with the capability to create and customize reports using XtraReports End-User Designer, if it is necessary to have a common target for saving and sharing all reports.

The default report serialization mechanism does not support the serialization of a report's datasource. The following examples illustrate how you can provide a custom XML serialization logic for a report's datasource as well as its custom parameters.

- How to implement custom XML serialization of a report that is bound to a dataset;

- How to serialize an XPO data source;

- How to serialize parameters of custom types.

Example Comments

Added By: at: 10/8/2012 1:48:21 PM    

There is a slight error in the example if you are using a different XPO provider. The call to create the XpoReportStorage is prior to setting the default DataLayer. This results in the default MS Access DataLayer being used in the XpoReportStorage parameter. Changing the statement (as indicated below) will result in the expected behavior:

string conn = SQLiteConnectionProvider.GetConnectionString(@"c:\temp\ReportStorage.sqlite");
XpoDefault.DataLayer = XpoDefault.GetDataLayer(conn, AutoCreateOption.DatabaseAndSchema);
reportStorage = new XpoReportStorage(new UnitOfWork());

Added By: Patrick Sollberger at: 7/6/2013 5:03:23 AM    

A hint for all those wo tried this with version 13.1.4:

This Example can not be built as-is using DevExpress 13.1.4 even after project conversion.

The ZipReportStorage.cs contains renamed classes:
- ZipFileCollection is now named InternalZipFileCollection
- ZipFile is now named InternalZipFile
- ZipArchive is now named InternalZipArchive

After renaming all occurences of those classes with the new names everything works just fine.

Inline pictures in RichEditControl

$
0
0

This example illustrates different methods used to create and insert inline pictures in the XtraRichEdit.

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

$
0
0

This example demonstrates how to use the new security system to implement the subject:

- Users (Joe, John) can view and edit their own tasks, but cannot delete them or create new ones. They also have readonly access to tasks, 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. You can see how it works in action at http://www.screencast.com/t/TBKEiCEfxc (or you can run functional tests in the MainDemo.EasyTests folder).


To do this:

1.Permissions at the type and object 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 JoinOperand 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. 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.
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.
2.The State of the New Security System

Example Comments

Added By: Raoulw at: 2/11/2013 5: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 10:31:27 AM    

Thanks for your update, Raoul!

How to create an ASPxGridView with custom pager with the "Selecting a page size" feature at Runtime


How to create a custom pager for the ASPxGridView with the "Selecting a page size" feature

$
0
0

A custom pager implementation can be performed by using separate controls. However, under certain circumstances (due to the control hierarchy recreation), it is difficult to implement this feature using a server-side code only.
This example demonstrates how to achieve the desired result using ASPxComboBoxes within the PageBar template.

See Also:
E358
How to create an ASPxGridView with custom pager with the "Selecting a page size" feature at Runtime

Example Comments

Added By: aviad penzak at: 7/8/2012 5:21:49 AM    

after selecting a page in the "cbPage" combobox the correct data in grid appears but the page number in the combobox control remains "1"
I am using the below code in update pannel

Added By: KDI at: 7/17/2013 2:37:12 AM    

Hi,

We want to achieve a similar functionality of creating a custom pager, but we are generating our grid at runtime in ".aspx.cs" file. Our grid is not declared/defined in .aspx file.
Is there a way to create PagerBar template using the C# code in .".aspx.cs" file? It would be gret if you can share a working example which serves this purpose.

Thanks.

How to display a hint popup for the edit field

How to allow Link/Unlink objects for a ManyToMany collection property when an end-user doesn't have permissions to modify the associated objects

$
0
0

Note: This solution can be applied only to the old Security System. In the new Security System, you can configure member permissions to grant access to the associated collections.

This example demonstrates a workaround for the S30570 suggestion while it is not implemented out-of-the-box.

Suppose, I have the Organization and Person classes. Each Person object can be associated with a number of Organization objects, and each Organization object can be associated with a number of Person objects (a many-to-many relationship, see the BusinessClasses.cs file):

[C#]
publicclassPerson:XPObject{publicPerson(Sessionsession):base(session){}publicstringName{get{returnGetPropertyValue<string>("Name");}set{SetPropertyValue<string>("Name",value);}}[Association("Organizations-Persons2")]publicXPCollection<Organization>Organizations{get{returnGetCollection<Organization>("Organizations");}}}publicclassOrganization:XPObject{publicOrganization(Sessionsession):base(session){}publicstringFullName{get{returnGetPropertyValue<string>("FullName");}set{SetPropertyValue<string>("FullName",value);}}[Association("Organizations-Persons")]publicXPCollection<Person>Persons{get{returnGetCollection<Person>("Persons");}}}

And, an end-user needs to modify any Person object, including its "Organizations" collection ('Link' or 'Unlink' organization objects), but he or she should not modify any property of an Organization object.

To accomplish this, I grant all operations under the Person objects and grant only the Read operation over the Organization objects (see the Updater.cs file):

[C#]
userRole.AddPermission(newObjectAccessPermission(typeof(object),ObjectAccess.AllAccess,ObjectAccessModifier.Allow));userRole.AddPermission(newObjectAccessPermission(typeof(Person),ObjectAccess.AllAccess,ObjectAccessModifier.Allow));userRole.AddPermission(newObjectAccessPermission(typeof(Organization),ObjectAccess.ChangeAccess,ObjectAccessModifier.Deny));

With these permissions, I have achieved the necessary behavior, except for that an end-user cannot modify the Organizations collection property. This is a restriction of the current implementation of the XAF Security system.

To avoid it, I introduce a new class and manually allow modifying the "Organizations" property in the code (see the AllowManyToMany_ObjectAccessComparer.cs file):

[C#]
publicclassAllowManyToMany_ObjectAccessComparer:ObjectAccessComparer{publicoverrideboolIsSubsetOf(ObjectAccessPermissionsourcePermission,ObjectAccessPermissiontargetPermission){if(sourcePermission.AccessItemList.Count== 1){ParticularAccessItemsourceAccessItem=sourcePermission.AccessItemList[0];if(typeof(Organization).IsAssignableFrom(sourceAccessItem.ObjectType)&&sourceAccessItem.Access==ObjectAccess.Write&&sourceAccessItem.Modifier==ObjectAccessModifier.Allow){if(sourcePermission.Contexts!=null&&sourcePermission.Contexts.CollectionPropertyContext!=null&&sourcePermission.Contexts.CollectionPropertyContext.CollectionPropertyName=="Organizations"&&typeof(Person).IsAssignableFrom(sourcePermission.Contexts.CollectionPropertyContext.MasterObjectType)){returntrue;}}}returnbase.IsSubsetOf(sourcePermission,targetPermission);}}

and set this class as the current ObjectAccessComparer in the main.cs and global.aspx.cs files:

[C#]
ObjectAccessComparerBase.SetCurrentComparer(newAllowManyToMany_ObjectAccessComparer());

Thanks,
Dan

dxMap - How to display step by step directions

$
0
0

This example illustrates how to display step by step directions using Google Maps API. See the Directions Steps topic to learn more.

How to bind dxLookup to WebService

Viewing all 7205 articles
Browse latest View live


Latest Images

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