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

How To: Implement Many-to-many Relations Editing

$
0
0

Starting with 15.2, Scaffolding Wizard supports generating many-to-many relations out of the box, so you don't need to implement it manually for a new application.

This example shows how to implement many-to-many relations editing in an application generated with the DevExpress Scaffolding Wizard.


The resulting application supports adding multiple Course objects to the Student.CoursesAttending detail collection and vice versa.

You can encounter the following exception:

A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll

Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)

This error is caused because the EntityFramework uses the missing LocalDB component.

To fix the issue, locate the App.config file within your application and open it. Change the defaultConnectionFactory in the following manner:

[XAML]
<defaultConnectionFactorytype="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>

How to Group Fields

$
0
0

The following code demonstrates how to combine fields into a group.

In this example, three fields (Year, Quarter and Month, respectively) are combined into a new group. This ensures that the Year field will be followed by Quarter which in its turn is followed by Month. If the Year field is being dragged to another area other fields will be dragged as well.

How to implement drag-and-drop between two Grids using MVVM

$
0
0

This example is the modified  Drag-and-drop data rows from one grid to another example. It demonstrates how to implement drag-and-drop functionality between two Grids using our MVVM framework. To implement drag and drop using the MVVM pattern, create a helper class (DragAndDropHelper class) that implements corresponding events (the "Drop" and "DeleteRecord" events) in a similar manner it is implemented in WPF. Arguments of these events are passed to corresponding ViewModel commands using the EventToCommand method.

Lesson 7 - Create a Custom Appointment Edit Form

$
0
0
Review the Lesson 7 - Create a Custom Appointment Edit Form help topic to learn how to create this project step-by-step.

 OBSOLETE: DashboardDesigner - How to customize data source wizard to display only predefined data connections

$
0
0

Update: starting with version 15.2, it is possible to disable creating new connections by setting the DashboardDesigner.DataSourceWizardSettings.DisableNewConnections property to True.  


This example demonstrates how to use the DashboardDesigner.DataSourceWizardCustomization to replace the default pages of the data source wizard with custom ones:

[C#]
dashboardDesigner1.DataSourceWizardCustomization=newDataSourceWizardCustomization();

 

We use following code to skip first page which allows selecting the data source type, and specify custom a wizard page that allows selecting one of the predefined connections. This custom page does not allow establishing a new connection:

[C#]
publicclassDataSourceWizardCustomization:IDashboardDataSourceWizardCustomization{publicvoidCustomizeDataSourceWizard(IWizardCustomization<DashboardDataSourceModel>customization){customization.StartPage=typeof(ChooseConnectionPage<DashboardDataSourceModel>);customization.Model.DataSourceType=DashboardDataSourceType.Xpo;customization.RegisterPageView<IChooseConnectionPageView,CustomChooseConnectionPageView>();}}

 

To specify default connections in code behind, use the DashboardDesigner.CustomDataConnections Property.  

See Also:
How to define a custom IConnectionStorageService in DashboardDesigner to filter out unnecessary connections from an app.config file  

Question Comments

Added By: mori khazaei 1 at: 7/29/2015 9:23:35 PM    

Hi,

I run this example. first no references is known and I add all again and then this error appear when I compile it:
'WizardCustomizationExample1.DataSourceWizardCustomization' does not implement interface member 'DevExpress.DashboardWin.ServiceModel.IDashboardDataSourceWizardCustomization.CustomizeDataSourceWizzard(DevExpress.DataAccess.UI.Wizard.IWizardCustomization<DevExpress.DashboardCommon.DashboardDataSourceModel>)'

The error is from DataSourceWizardCustomization1.cs line 49 column 18

how can I resolve this error?

Added By: Constant (DevExpress Support) at: 7/30/2015 12:39:46 AM    

The problem likely appears because you use the Dashboard Suite version, which does not support this functionality. This interface and other required members were introduced only in version 15.1.5. If you use an older version, it is necessary to upgrade it to use this functionality. 

Added By: Genesis Supsup 1 at: 12/12/2015 8:52:23 PM    

Does this work in 15.2 or higher versions?

Added By: Constant (DevExpress Support) at: 12/14/2015 8:14:28 AM    

Starting with version 15.2, it is possible to disable creating new connections by setting the DashboardDesigner.DataSourceWizardSettings.DisableNewConnections property to True

Added By: Akhil Chauhan at: 2/10/2016 1:12:23 AM    Hi ,


I am using EntityFramework complied dll for Datasource. Could you please have sample same as below for EF Pageview. So that I could set default dll without browse option for user.
Added By: Constant (DevExpress Support) at: 2/10/2016 5:33:26 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T344122: Data Source Wizard - How to select certain EF assembly by default. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

GridView - How to export filtered data with Reports when using the BindToLINQ method with large data

$
0
0

At present our MVCxGridView export mechanism has some limitations: it is impossible to export a lot of filtered data, because the mechanism requests all data from a database and then filters it. Thus, a request can be fulfilled, and the 'System.OutOfMemoryException' exception occurs. As a solution, request filtered data yourself and export it using the XtraReports Suite. This example demonstrates how you can do this using LINQ-to-SQL.

To pass the FilterExpression to a Controller's Action, obtain and save it to GridView CustomJSProperties in CustomJSProperties:


[C#]
settings.CustomJSProperties=(s,e)=>{ASPxGridViewgrid=(ASPxGridView)s;e.Properties["cpGridFilterExpression"]=grid.FilterExpression;};settings.CustomJSProperties=Sub(s,e)DimgridAsASPxGridView=DirectCast(s,ASPxGridView)e.Properties("cpGridFilterExpression")=grid.FilterExpressionEndSub

When a user clicks the Export data, take the filter expression from GridView CustomJSProperties and add it to the collection of jQuery selector parameters.

[JScript]
function OnClick(s, e){var actionParams = $("form").attr("action").split("?filterString="); actionParams[1] = gvDataBindingToLinq.cpGridFilterExpression; $("form").attr("action", actionParams.join("?filterString="));}

You can learn more about approaches used in this example in the following resources:

How to: Create a Table Report
How to create a web based report at runtime
How to convert the CriteriaOperator to a lambda expression, so, the latter expression can be used in the IQueriable source

GridView Extension - Provide the capability to export large LINQ data
Walkthrough: Installing the AdventureWorks Database

Question Comments

Added By: Kevin Turpin 1 at: 2/10/2016 11:50:47 AM    OK, i absolutely love that i can do this, nicely done.

How to put a custom UserControl in a GridView cell

$
0
0

NOTE:
This example is created only for demonstration purposes and we don't recommend using this approach in your application, because it has many limitations and requires writing a lot of custom code. If none of DevExpress XtraEditors are suitable for you and you want to put a custom control in a GridControl cell, pleasecontact DevExpress support and describe the desired layout to us. We will do our best to find an acceptable solution for you.

This example demonstrates how a custom UserControl can be used as an in-place editor in GridView, TreeList, Ribbon and Vertical Grid. As described in the A128 Knowledge Base, it is not possible to just place a control within a cell, because cells are not controls. When a cell's editor is not activated, its content is drawn via a painter. So, in our example, we have created a painter to draw the entire UserControl's content. All cells in GridView will be drawn using this painter until an end-user clicks a cell. In this case, an actual instance of the UserControl class will be created. Controls inherited from the BaseEdit class are drawn via their painters, other controls are drawn via the DrawToBitmap function. In case of 3rd-party controls, you need to draw them manually. If you want to use your custom control in GridView or other controls, you need to implement the IEditValue interface in it.

See also: How to work with the editor's painter, and view info classes in a descendant

Question Comments

Added By: Jaix Software at: 3/6/2013 8:05:36 PM    

This example does not work with DateEdit in a menu bar. There appears to be a display issue, as when focus is lost nothing is display. Re-selecting the control and the dates come back.

Added By: D. Samsonoff at: 4/25/2013 2:58:12 AM    

You probably would want to expose Control rather than UserControl to meet broader requirements.

Added By: Christophe Keller @ PTS at: 12/12/2013 1:34:26 AM    

Hi,

In your example, if I click on a different cell in the table in Form1, the cell turns white for a short amount of time before the editor is active. How can I avoid this?

Added By: Satwant Sandhu at: 2/10/2016 7:59:07 AM    How do we modify this so that the custom control is only used when editing.  I have a custom text box that I use for entry, but once the user is no longer in edit mode then I want to show the default cell rendered (i.e. a label).

I do not want my custom editor being painted in every cell. Added By: Svetlana (DevExpress Support) at: 2/10/2016 11:46:58 PM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T344393: How to use a custom editor only for editing in a grid. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

How to show images for Tentative and Working Elsewhere appointment statuses

$
0
0
The following example illustrates how to create custom templates for vertical and horizontal appointments, and override the status displayed for these appointments.
By default, the Tentative and Working Elsewhere statuses are displayed as a colored line inside the appointment area of ASPxScheduler. Meanwhile, it's possible to display required images for these statuses in the same manner supported by MS Outlook. The example uses Div elements with repeating background images inside appointment templates for this purpose. Switch the Div visibility to show images or the default status line according to the current appointment status and the status displaying mode (Never, Time, or Bounds) of the active Scheduler view.

Refer to the How to: Customize Appointment Appearance via Templates documentation article to get more information about the appointment templates customization.

How to connect a Pivot Grid to an OLAP datasource

$
0
0
If you have a cube on the OLAP server (Microsoft Analysis Services 2000, 2005, 2008, 2008 R2, 2012 and 2014), you can view its data using the Pivot Grid. In this example, you will see how to specify connection settings to the server and create fields that represents specific measures and dimensions of the cube.

To bind the Pivot Grid control to an OLAP cube, follow the steps below.

1. Set ADOMD as a data provider using the PivotGridControl.OLAPDataProvider property.
2. Specify connection settings to the server using the PivotGridControl.OLAPConnectionString property. The connection string used in the example is shown below.
OlapConnectionString="Provider=MSOLAP;Data Source=http://demos.devexpress.com/Services/OLAP/msmdpump.dll;Initial catalog=Adventure Works DW Standard Edition;Cube name=Adventure Works;Query Timeout=100;"
3. Create fields for all the measures and dimension in the bound OLAP cube, and moves these fields to the specified area, making them hidden. To do it, use the PivotGridControl.RetrieveFields method overload and set the field's visibility to false.
4. Place some of the created fields within corresponding Pivot Grid Control areas (Data Header Area, Column Header Area, Row Header Area or Filter Header Area) and set the visibility of the fields to true using the PivotGridFieldBase.Visible property.

Use the invoked Customization Form to specify the Pivot Grid control's layout.

To learn more about OLAP Datasources, see OLAP Datasources.

How to store data to a local file using PhoneGap API

$
0
0

This example demonstrates how to store data to a local file using PhoneGap API. To access a corresponding API, it is necessary to add a link to the cordova.js file.

This example can be tested only on a mobile device.

See also:
PhoneGap Documentation - File
How to build a native package in Visual Studio
How to test PhoneGap API via the Courier tool

Question Comments

Added By: Andrea Tatone at: 7/25/2013 11:14:40 AM    

Many thanks for the example. I've tried it in the simulator and the courier, but it doesn't work (i'm working on a android 2.3.4 device). It fails with the message "File system is not accessible", either in read and write. Is there anything I can do?

Added By: Nikolai (DevExpress Support) at: 7/25/2013 11:18:07 PM    

Hi Andrea,

I have created a separate ticket regarding this issue. Please post all messages here Q377803.

Added By: Rakesh Parab at: 5/28/2014 12:15:35 AM    

plz help me 4.......
how to store .csv file to particular path in mobile like /mnt/sdcard/csvfiles .
???

Added By: Nikolai (DevExpress Support) at: 5/28/2014 7:09:53 AM    Hi Rakesh,

I have created a separate ticket for this issue How to store a file to a particular folder. Please post all comments in this ticket.Added By: User name 5 at: 2/10/2016 1:56:40 PM    I just have a couple questions on how this works: 

1. what exactly does this function do
app.fileSystem.root.getFile("test.txt", { create: true }, GetFileEntryWriter, FileSystemFail);

2. and when you are calling the GetFileEntryWriter function you aren't passing any parameters, when it is expecting the fileEntry argument. So wouldn't that make the fileEntry.createWriter(WriteFile, FileSystemFail) function not work, as it would say cannot get method of undefined field fileEntry.

3. Why separate some javascript functions into the app.html page and the others into the index.js page? 

Thanks for the help Added By: User name 5 at: 2/10/2016 1:58:41 PM    4. Plus how do I access the functions in the app.html page from the index.js page, if it is possible 

Thanks again Added By: Nikolai (DevExpress Support) at: 2/11/2016 1:00:50 AM    Hi,

Here are my comments:
1, 2, This is the File plugin API. The decription of this plugin can be found here.
3. This is just an example. There is no specific reason for declaring functions in app.html file. The main requirement is that file syste should be initialized when device is ready. This inquiry is better related to basic PhoneGap concepts rather that to DevExtreme. I suggest that you refer to the PhoneGap Documentation to learn more.
4. If you wish to access functions an any part of your code, declare them in the global context as it is done for the gotFS function.


Added By: User name 5 at: 2/11/2016 5:56:33 AM    Hi Nikolai, 

Thanks for the help, really appreciate it Added By: Nikolai (DevExpress Support) at: 2/11/2016 6:00:59 AM    My pleasure :)

How to show color icons for labels and statuses in the Appointment Edit Form and Popup Menu

$
0
0

By default, the Show Time As and Label As popup menu items, and label and status editors in the Appointment Edit Form provide only a text description of the corresponding labels and statuses. This example illustrates how to enhance the appearance of the built-in Label and Status editors, and show icons reflecting exact label/status colors in these cases. All required images for the built-in Labels and Statuses are located in the Image folder of the example. 

To show icons for the menu items of the Popup Menu, handle the ASPxScheduler.PopupMenuShowing event and assign an image path to the MenuItem.Image.Url property of the required menu items.
To show color icons for the label and status editors in the Appointment Edit Form, create a custom edit form, and assign the Url value to the ListEditItem.ImageUrl property for each item of the label and status ASPxComboBox controls.

Refer to the How to: Customize a Form Using Templates documentation article describing the standard approach of the appointment edit form customization.

How to connect ASPxPivotGrid to an OLAP datasource

$
0
0
If you have a cube on the OLAP server (Microsoft Analysis Services 2000, 2005, 2008, 2008 R2, 2012 and 2014), you can view its data using the ASPxPivotGrid control. In this example, you will see how to specify connection settings to the server and create fields that represents specific measures and dimensions of the cube.

To bind the Pivot Grid control to an OLAP cube, follow the steps below.

1. Set ADOMD as a data provider using the ASPxPivotGrid.OLAPDataProvider property.
2. Specify connection settings to the server using the ASPxPivotGrid.OLAPConnectionString property. The connection string used in the example is shown below.
OlapConnectionString="Provider=MSOLAP;Data Source=http://demos.devexpress.com/Services/OLAP/msmdpump.dll;Initial catalog=Adventure Works DW Standard Edition;Cube name=Adventure Works;Query Timeout=100;"
3. Create fields for all the measures and dimension in the bound OLAP cube, and moves these fields to the specified area, making them hidden. To do it, use the ASPxPivotGrid.RetrieveFields method overload and set the field's visibility to false.
4. Place some of the created fields within corresponding Pivot Grid Control areas and set the visibility of the fields to true using the PivotGridFieldBase.Visible property.

Use the invoked Customization Form to specify the Pivot Grid control's layout.

To learn more about OLAP Datasources, see OLAP Datasources.

How to connect a Pivot Grid to an OLAP datasource

$
0
0
If you have a cube on the OLAP server (Microsoft Analysis Services 2000, 2005, 2008, 2008 R2, 2012 and 2014), you can view its data using the Pivot Grid. In this example, you will see how to specify connection settings to the server and create fields that represents specific measures and dimensions of the cube.

To bind the Pivot Grid control to an OLAP cube, follow the steps below.

1. Set ADOMD as a data provider using the PivotGridControl.OlapDataProvider property.
2. Specify connection settings to the server using the PivotGridControl.OlapConnectionString property. The connection string used in the example is shown below.
OlapConnectionString="Provider=MSOLAP;Data Source=http://demos.devexpress.com/Services/OLAP/msmdpump.dll;Initial catalog=Adventure Works DW Standard Edition;Cube name=Adventure Works;Query Timeout=100;"
3. Create fields for all the measures and dimension in the bound OLAP cube, and moves these fields to the specified area, making them hidden. To do it, use the PivotGridControl.RetrieveFields method overload and set the field's visibility to false.
4. Place some of the created fields within corresponding Pivot Grid Control areas and set the visibility of the fields to true using the PivotGridField.Visible property.

Use the invoked Customization Form to specify the Pivot Grid control's layout.

To learn more about OLAP Datasources, see OLAP Datasources.

How to bind a chart title to a content template

$
0
0
This example demonstrates how to use the data template for a chart title content.

GridView - How to implement cascaded combo boxes in the EditForm


How to create a custom action type with a custom control in Web

$
0
0

This example demonstrates how to create a custom action that accepts two parameters (a DateTime range), how to extend the web ActionContainerHolder to create a custom action item with a complex control. The code is based on the built-in ParametrizedAction item. Note that it is required to place a custom ActionContainerHolder to our web templates (aspx pages) instead of the default ActionContainerHolder, otherwise a custom action item will not be created. See how this is done in the DefaultTemplateContent1.ascx file. For additional information, refer to the How to: Customize an ASP.NET Template topic.

How to: Load an External Window or UserControl into a DocumentPanel

$
0
0

You can define a Window, Page or UserControl in external XAML files and then, with DXDocking, load their contents into DocumentPanel objects.

This example demonstrates how to load an external Window and UserControl into DocumentPanels.

In the example three approaches are demonstrated:

1) The contents of MyWindow.xaml is loaded into a DocumentPanel at design time (in XAML) via the DocumentPanel.Content property. The Content property accepts a Uri object, which must refer to a XAML file defining a Window, Page or UserControl.

[XAML]
<dxdo:DocumentPanelx:Name="docPanel2"Caption="Panel 2"Content="{dxdo:RelativeUri UriString=CustomWindows\\MyWindow.xaml}"/>


2) The DocumentPanel.Content property is set with a Uri object at runtime:

[C#]
docPanel1.Content=newUri(@"CustomWindows\MyWindow1.xaml",UriKind.Relative);

 

3) The DockLayoutManager.DockController.AddDocumentPanel method creates a new DocumentPanel object and loads the contents of an external XAML file into the created panel.

[C#]
panel1=dockLayoutManager1.DockController.AddDocumentPanel(documentGroup1,newUri(@"CustomWindows\UserControl1.xaml",UriKind.Relative));panel1.Caption="Document "+(ctr++).ToString();

In the example, the XAML file defines a UserControl object. The loaded UserControl is accessed via the DocumentPanel's Control property and then a method on the UserControl is invoked.

[C#]
//...(panel1.ControlasUserControl1).SetDataContext(imageInfo);

You can see this in action by clicking the "Set DataContext for UserControl" button in the example.

Question Comments

Added By: Sudha Raman at: 10/22/2013 9:21:47 AM    

Hi,

 I am following the same approach in my project. My question is how to close the Usercontrol from Button click event of it.(not using the 'X' on right corner- usercontrol unloaded event).

Thanks
Sudha.

Added By: Alex Zeller (DevExpress) at: 10/23/2013 1:00:47 AM    

Hi,
If you have a button within a UserControl displayed within a DocumentPanel, you can use the Button.Click event to close the current DocumentPanel:
private void button1_Click(object sender, RoutedEventArgs e) {
    DockLayoutManager dm = DockLayoutManager.GetDockLayoutManager(this);
    dm.DockController.Close(dm.ActiveDockItem);
}
Thanks, Alex.

Added By: Cotza Andrea at: 11/20/2013 1:56:14 AM    

Hi,

 I've a windows (MDI) with buttons (save, new ecc.) and document panel with loaded windows at runtime. I need to send commands from child windows to MDI window (enable/disable buttons). How can I do?

Thanks, Andrea.

Added By: ali jumaa 6 at: 2/13/2016 2:55:26 AM    I can't understand how I can fill a content property for document panel with external xaml file
please I need a simple project for this as soon as possible. 

many thanks 

How to use CSS to customize dashboard items in ASPxDashboardViewer

$
0
0

This example shows how to use CSS (Cascading Style Sheets) to change visual styles of dashboard items in ASPxDashboardViewer. The following settings are customized:

- Font sizes used in the List Box and Pivot Grid.

- A background color of cards displayed within the Card dashboard item.

How to: customize item appearance on the Hidden Items tab in the Customization window

$
0
0

This example demonstrates how to override a style for the HiddenItemsPanel control to show items on the Hidden Items tab as a tree.

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.

Viewing all 7205 articles
Browse latest View live


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