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

RiaInstantFeedbackDataSource - How to show included entity field data in DXGrid using custom DB View

$
0
0

This example shows how to create a new custom View that will include data from two dependent data tables.


Let's assume you need to show the Orders table content in DXGrid using the RiaInstantFeedbackDataSource. The Order entity has the CustomerID field and you may wish to display information about order's customer within the grid. For example, show the customer's name from the Customers table along with the CustomerID.

The easiest way to accomplish this task is to create a new View in the database that will include data from both the Orders and Customer tables. This can be done on the server side using the following SQL script:

[SQL]
CREATE VIEW [dbo].[CustomerOrders] AS SELECT OrderID, CompanyName, ContactName, OrderDate FROM Orders inner join Customers on Orders.CustomerID = Customers.CustomerID

Now, when the new View is ready, you'll need to create an ADO.Net Entity Data Model based on this custom view and create a Domain Service based on this model. The required steps are similar to those shown in the 'How to: Use DXGrid with RIA Services' help topic. The only difference is that it is necessary to choose the new custom View in the 'Choose Your Data Base Object' data model wizard's dialog rather than Orders table.

As a result, a model with the following diagram will be created:

An alternative approach is to use the extended data query and join data from two tables within the Domain Service GetCustomerOrders method. Please refer to the RiaInstantFeedbackDataSource - How to show included entity field data in DXGrid using the extended data query example to see this approach in action.


Question Comments

Added By: rasool jalali at: 5/19/2015 7:25:09 AM    

Hi dear
I want to use RiaInstantFeedbackDataSource  in my silverligt project but this not exist in xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
or DevExpress.Xpf.Core.ServerMode namespace.
Where is my mistake ?
Please help me


ASPxGridView - Search Panel - How to search and highlight text placed in the PreviewRow

$
0
0

The Search Panel can find text only from visible grid columns. So, it is necessary to create a column with a field that contains a PreviewRow. It is possible to hide it using the CSS styles:

[ASPx]
<dx:GridViewDataTextColumnFieldName="Description"VisibleIndex="2"><HeaderStyleCssClass="hiddenColumn"/><EditCellStyleCssClass="hiddenColumn"/><CellStyleCssClass="hiddenColumn"/><FilterCellStyleCssClass="hiddenColumn"/><FooterCellStyleCssClass="hiddenColumn"/><GroupFooterCellStyleCssClass="hiddenColumn"/></dx:GridViewDataTextColumn>
[CSS]
.hiddenColumn{display:none;}

 Then, it is necessary to highlight the found text manually in the same manner as performed in the ASPxGridView - Search Panel - How to highlight the text placed inside a DataItem template example.

[OBSOLETE] How to specify dashboard parameter values on the client side

$
0
0

The following example demonstrates how to specify dashboard parameter values on the client side.

In this example, the ASPxClientDashboardViewer.ReloadData method reloads data in the data sources and accepts two dashboard parameters with the specified default values. This method is called in the Click event handler of the ASPxButton1.

In version 14.2 the void ReloadData(ASPxClientDashboardParameter[] parameters) method is obsolete. Use the approach described in the How to specify dashboard parameter values on the client side in the Web Viewer example instead.

How to provide in-place editors for row headers in a vertical grid

$
0
0

This example demonstrates how to manually draw an editor in row headers and activate them on a mouse click. To implement this functionality in a project, it’s necessary to:

- Add the DrawEditorHelper and RowInplaceEditorHelper classes to the solution;

- Create a RowInplaceEditorHelper class instance and set the vertical grid’s row and a corresponding repository item as parameters.

 

How to create and show a badge notification icon like in iOS

$
0
0
This example illustrates how to use internal DXLayeredWindowEx class to show a layered window within a control. 
Badge animation and handling a click event on a badge is not supported.
Question Comments

Added By: Alisher (DevExpress Support) at: 5/20/2015 7:21:55 AM    

If you have issues with visibility of icon when it is overlapped with other windows, see https://isc.devexpress.com/Thread/WorkplaceDetails/T243609

WinForms SchedulerControl API

$
0
0
This example demonstrates how to manage WinForms Scheduler control programmatically.
The application includes several RichEditControls at the top used to display and edit the code and  SchedulerControl (at the bottom) which shows the result of code execution. There are two groups of tabs displaying code - one for C# and another for VB languages. Each group is composed of the main tab displaying the main executable code and the tab which displays the code of the helper class used in the main code snippet. Generally the helper class is not required and the corresponding tab is empty.
You can modify the code and watch the result. The code is executed two seconds after it is modified. If an error occurs during compilation or execution, the code window background color turns to pink.

ASPxGridView - Batch Editing - How to cancel editing or disable the editor conditionally

$
0
0

This example demonstrates how to cancel editing or disable the editor conditionally for the grid when batch editing is in use. It is possible to execute your logic either on the client or server side for a complex business model.
Then, handle the grid's client-side BatchEditStartEditing event to either cancel the edit operation using the e.cancel property:

[JScript]
if(condition) e.cancel = true;

 or disable the editor by obtaining its client instance:

[JScript]
var editor = s.GetEditor(e.focusedColumn.fieldName); editor.SetEnabled(condition);

 The custom server-side logic can be executed in the CustomJSProperties event handler:

[C#]
protectedvoidASPxGridView1_CustomJSProperties(objectsender,DevExpress.Web.ASPxGridView.ASPxGridViewClientJSPropertiesEventArgse){varclientData=newDictionary<int,object>();vargrid=senderasASPxGridView;for(inti=grid.VisibleStartIndex;i<grid.VisibleStartIndex+grid.SettingsPager.PageSize;i++){varrowValues=grid.GetRowValues(i,newstring[]{"ID","ServerSideExample"})asobject[];varkey=Convert.ToInt32(rowValues[0]);if(key% 2 != 0)clientData.Add(key,"ServerSideExample");}e.Properties["cp_cellsToDisable"]=clientData;}

 

See Also:
ASPxGridView - How to disable editing for rows that match some condition in Batch Edit Mode
GridView - Batch Editing - How to cancel editing or disable the editor conditionally

Question Comments

Added By: Phil George at: 5/20/2015 4:58:27 AM    

Is there a better way to handle this? I have a grid with 700,000 rows which now loads really quickly using a linq datasource but when I add in the code to conditionally allow editing on rows which match a certain criteria, the load times are shocking as it looks at every row instead of the rows visible on the screen. And it does this when paging.
I have a boolean column which is returned which determines if the row is editable for the current user - how can I use this column to make my code more efficient.

Added By: Anthony (DevExpress Support) at: 5/20/2015 8:37:56 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T244791: ASPxGridView - Batch Editing - How to cancel editing or disable the editor conditionally when Server mode is used. This ticket is currently in our processing queue. Our team will address it soon.

Custom form, custom fields and custom actions on reminder alert

$
0
0

The problem:

I have scanned the support center issues and couldn't find a answer. Here is what I want to do:

1) Create an appointment with custom fields and an alarm
2) Add occurrence for that appointment with alarm as well
3) Prevent the alarm from showing and insert my own code for all occurrences
4) Being able to access the custom fields data for all occurrences
5) Dismiss the handled recurrent appointment

The solution:

To accomplish the required tasks, perform the following actions:
Run the attached project. Click the "Create appointment with reminder" button. See the appointment series created at a current time of the day. The alert will be fired in one minute. Before it happens, open the newly created today's appointment, change its "Price" value and save modifications. When the reminder is triggered, a new appointment is created with a Subject line informing of the changed value for the Price custom field.

See Also:
How to bind ASPxScheduler to ObjectDataSource
How to bind ASPxScheduler to MS SQL Server database
How to bind ASPxScheduler to XPO via the Unit of Work
How to bind ASPxScheduler to SyBase ASE 15 database

Question Comments

Added By: Muhammed Yasir at: 5/21/2015 1:08:12 AM    

Reminder is now showing.. and why price is always 15?

Added By: Andrey (DevExpress Support) at: 5/21/2015 1:53:24 AM    

Hello,

In this example, the reminder form should not appear as it is mentioned in the annotation's point 3.
The Price field is always equal to 15, because this value is assigned in the ExecuteCore method of the CreateAppointmentWithReminderCallbackCommand class.

 

Should you have further questions, let me know.


How to prevent the Group Row from being selected

$
0
0

This example demonstrates how to allow a user to select only data rows when the GridView is grouped by any columns.

Question Comments

Added By: Sebastian Walden at: 5/21/2015 1:26:40 AM    

Problem with that solution:
If you have several groups and all of them are closed and if you then expand the last group, the first group is also expanded automatically because the focus is set to focusedrowhandle 0.
I can't figure out how to solve that.

Added By: Uriah (DevExpress Support) at: 5/21/2015 2:27:01 AM    

Hello Sebastian,

To process your recent post more efficiently, I created a separate ticket on your behalf: T245100: How to prevent group row auto expanding when a child row is focused. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

How to place LayoutPanel into the Group, GroupBox, or Tabbed group

$
0
0
By default DXDocking doesn't allow you to place LayoutPanels to the GroupBox or Tabbed group. This example demonstrates how to create a custom LayoutGroup descendant to override this behavior.

To learn more on how to implement similar functionality in WPF, refer to the E4064 example.

How to place LayoutPanel into the Group, GroupBox, or Tabbed group

$
0
0

By default DXDocking doesn't allow you to place LayoutPanels to the GroupBox or Tabbed group. This example demonstrates how to create a custom LayoutGroup descendant to override this behavior.

To learn more on how to implement similar functionality in Silverlight, refer to the T245263 example.

How to: Use DependencyPropertyBehavior

$
0
0
This example demonstrates how to use the DependencyPropertyBehavior.
Review this documentation topic to learn more.

To learn more on how to implement similar functionality in WPF, refer to the T122997 example.

How to: Use DependencyPropertyBehavior

$
0
0
This example demonstrates how to use the DependencyPropertyBehavior.
Review this documentation topic to learn more.

To learn more on how to implement similar functionality in Silverlight, refer to the T245301 example.

How to implement CRUD operations using DXGrid and eXpress Persistent Objects

$
0
0

This example shows how to use XPInstantFeedbackSource or XPServerCollectionSource with DXGrid, and how to implement CRUD operations (e.g., add, remove, edit) in your application via special behavior.

The test sample requires the SQL Express service and MSAccess to be installed on your machine.

We have created the XPOServerModeCRUDBehavior and XPOInstantModeCRUDBehavior attached behaviors for GridControl. For instance:

[XML]
<dxg:GridControl><i:Interaction.Behaviors><crud:XPOServerModeCRUDBehavior.../></i:Interaction.Behaviors></dxg:GridControl>

 

The XPServerModeCRUDBehavior and XPInstantModeCRUDBehavior classes contain the NewRowForm and EditRowForm properties to provide the "Add Row" and "Edit Row" actions. With these properties, you can create the Add and Edit forms according to your requirements:

[XML]
<DataTemplatex:Key="EditRecordTemplate"><StackPanelMargin="8"MinWidth="200"><Grid><Grid.ColumnDefinitions><ColumnDefinition/><ColumnDefinition/></Grid.ColumnDefinitions><Grid.RowDefinitions><RowDefinition/><RowDefinition/></Grid.RowDefinitions><TextBlockText="ID:"VerticalAlignment="Center"Grid.Row="0"Grid.Column="0"Margin="0,0,6,4"/><dxe:TextEditx:Name="txtID"Grid.Row="0"Grid.Column="1"EditValue="{Binding Path=Id, Mode=TwoWay}"Margin="0,0,0,4"/><TextBlockText="Name:"VerticalAlignment="Center"Grid.Row="1"Grid.Column="0"Margin="0,0,6,4"/><dxe:TextEditx:Name="txtCompany"Grid.Row="1"Grid.Column="1"EditValue="{Binding Path=Name, Mode=TwoWay}"Margin="0,0,0,4"/></Grid></StackPanel></DataTemplate><crud:XPServerModeCRUDBehaviorNewRowForm="{StaticResource ResourceKey=EditRecordTemplate}"EditRowForm="{StaticResource ResourceKey=EditRecordTemplate}"/>

This Behavior classes requires the following information from your data model:

- XPObjectType - the type of rows;

- DataServiceContext - database entities;

- PrimaryKey - the primary key of the database table;

- CollectionSource/InstantCollectionSource - an object of the EntityServerModeDataSource type.

[XML]
<dxg:GridControl><i:Interaction.Behaviors><crud:XPOServerModeCRUDBehaviorXPObjectType="{x:Type local:Items}"CollectionSource="{Binding Collection}"PrimaryKey="Id"/></i:Interaction.Behaviors></dxg:GridControl>

The XPInstantModeCRUDBehavior class for SL contains the ServiceHelper property, which refers to an object that provides actions to work with databases

[C#]
helper.ServiceHelper=newServiceHelper(helper,newUri("http://localhost:54177/WcfDataService.svc/"));

See the XPInstantFeedbackSource and XPServerCollectionSource classes to learn more about XPInstantFeedbackSource and XPServerCollectionSource.

Behavior class descendants support the following commands: NewRowCommand, RemoveRowCommand, EditRowCommand. You can bind your interaction controls with these commands with ease. For instance:

[XML]
<crud:XPOServerModeCRUDBehaviorx:Name="helper"/><StackPanelGrid.Row="1"Orientation="Horizontal"HorizontalAlignment="Center"><ButtonHeight="22"Width="60"Command="{Binding Path=NewRowCommand, ElementName=helper}">Add</Button><ButtonHeight="22"Width="60"Command="{Binding Path=RemoveRowCommand, ElementName=helper}"Margin="6,0,6,0">Remove</Button><ButtonHeight="22"Width="60"Command="{Binding Path=EditRowCommand, ElementName=helper}">Edit</Button></StackPanel>

By default, the XPOServerModeCRUDBehavior and XPOInstantModeCRUDBehavior solution support the following end-user interaction capabilities:

1. An end-user can edit selected row values by double-clicking on a grid row or by pressing the Enter key if the AllowKeyDownActions property is True.

2. An end-user can remove selected rows via the Delete key press if the AllowKeyDownActions property is True.

3. An end-user can add new rows, remove and edit them via the NewRowCommand, RemoveRowCommand, and EditRowCommand commands.


To learn more on how to implement similar functionality in Silverlight, refer to the T245411 example.

How to change the editor style within BarEditItem

$
0
0

This example demonstrates how to change the style (foreground, font size, etc.) of an editor within BarEditItem.

To learn more on how to implement similar functionality in Silverlight, refer to the T245477 example.


How to implement CRUD operations using DXGrid and eXpress Persistent Objects

$
0
0


This example shows how to use XPInstantFeedbackSource or XPServerCollectionSource with DXGrid, and how to implement CRUD operations (e.g., add, remove, edit) in your application via special behavior.

The test sample requires the SQL Express service and MSAccess to be installed on your machine.

We have created the XPOServerModeCRUDBehavior and XPOInstantModeCRUDBehavior attached behaviors for GridControl. For instance:

[XML]<dxg:GridControl><i:Interaction.Behaviors><crud:XPOServerModeCRUDBehavior .../></i:Interaction.Behaviors></dxg:GridControl>

 

The XPServerModeCRUDBehavior and XPInstantModeCRUDBehavior classes contain the NewRowForm and EditRowForm properties to provide the "Add Row" and "Edit Row" actions. With these properties, you can create the Add and Edit forms according to your requirements:

[XML]<DataTemplate x:Key="EditRecordTemplate"><StackPanel Margin="8" MinWidth="200"><Grid><Grid.ColumnDefinitions><ColumnDefinition/><ColumnDefinition/></Grid.ColumnDefinitions><Grid.RowDefinitions><RowDefinition/><RowDefinition/></Grid.RowDefinitions><TextBlock Text="ID:" VerticalAlignment="Center" Grid.Row="0" Grid.Column="0" Margin="0,0,6,4" /><dxe:TextEdit x:Name="txtID" Grid.Row="0" Grid.Column="1" EditValue="{Binding Path=Id, Mode=TwoWay}" Margin="0,0,0,4" /><TextBlock Text="Name:" VerticalAlignment="Center" Grid.Row="1" Grid.Column="0" Margin="0,0,6,4" /><dxe:TextEdit x:Name="txtCompany" Grid.Row="1" Grid.Column="1" EditValue="{Binding Path=Name, Mode=TwoWay}" Margin="0,0,0,4" /></Grid></StackPanel></DataTemplate><crud:XPServerModeCRUDBehavior NewRowForm="{StaticResource ResourceKey=EditRecordTemplate}" EditRowForm="{StaticResource ResourceKey=EditRecordTemplate}"/>

This Behavior classes requires the following information from your data model:

- XPObjectType - the type of rows;

- DataServiceContext - database entities;

- PrimaryKey - the primary key of the database table;

- CollectionSource/InstantCollectionSource - an object of the EntityServerModeDataSource type.

[XML]<dxg:GridControl><i:Interaction.Behaviors><crud:XPOServerModeCRUDBehavior XPObjectType="{x:Type local:Items}" CollectionSource="{Binding Collection}" PrimaryKey="Id"/></i:Interaction.Behaviors></dxg:GridControl>

The XPInstantModeCRUDBehavior class for SL contains the ServiceHelper property, which refers to an object that provides actions to work with databases

[C#]helper.ServiceHelper = new ServiceHelper(helper, new Uri("http://localhost:54177/WcfDataService.svc/"));
See the XPInstantFeedbackSource and XPServerCollectionSource classes to learn more about XPInstantFeedbackSource and XPServerCollectionSource.

 

Behavior class descendants support the following commands: NewRowCommand, RemoveRowCommand, EditRowCommand. You can bind your interaction controls with these commands with ease. For instance:

[XML]<crud:XPOServerModeCRUDBehavior x:Name="helper"/><StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center"><Button Height="22" Width="60" Command="{Binding Path=NewRowCommand, ElementName=helper}">Add</Button><Button Height="22" Width="60" Command="{Binding Path=RemoveRowCommand, ElementName=helper}" Margin="6,0,6,0">Remove</Button><Button Height="22" Width="60" Command="{Binding Path=EditRowCommand, ElementName=helper}">Edit</Button></StackPanel>

By default, the XPOServerModeCRUDBehavior and XPOInstantModeCRUDBehavior solution support the following end-user interaction capabilities:

1. An end-user can edit selected row values by double-clicking on a grid row or by pressing the Enter key if the AllowKeyDownActions property is True.

2. An end-user can remove selected rows via the Delete key press if the AllowKeyDownActions property is True.

3. An end-user can add new rows, remove and edit them via the NewRowCommand, RemoveRowCommand, and EditRowCommand commands.


To learn more on how to implement similar functionality in WPF, refer to the E3868 example.

How to change the editor style within BarEditItem

$
0
0

This example demonstrates how to change the style (foreground, font size, etc.) of an editor within BarEditItem.

To learn more on how to implement similar functionality in WPF, refer to the E3408 example.

How to activate panels via ViewModel

$
0
0

This example shows how to activate a panel via two-way binding in the BaseLayoutItem.IsActive property. After changing an active panel, a corresponding ViewModel is activated. And after changing the active ViewModel, the active panel is passed to DockLayoutManager.


To learn more on how to implement similar functionality in WPF, refer to the E3976 example.

How to activate panels via ViewModel

$
0
0

This example shows how to activate a panel via two-way binding in the BaseLayoutItem.IsActive property. After changing an active panel, a corresponding ViewModel is activated. And after changing the active ViewModel, the active panel is passed to DockLayoutManager.

To learn more on how to implement similar functionality in Silverlight, refer to the T245249 example.

How to: Build a dock UI using the MVVM pattern

$
0
0

This example shows how to build a dock UI using the MVVM pattern.

To learn more on how to implement similar functionality in Silverlight, refer to the T245345 example.

Question Comments

Added By: David Lemieux at: 12/3/2013 5:38:24 AM    

How come the view should be responsible of creating documents and panels? In a true MVVM design this should be the ViewModel's responsibility.

Added By: David Lemieux at: 12/5/2013 8:17:17 AM    

Is anyone from DevExpress monitoring comments on examples?

Added By: Alex Zeller (DevExpress) at: 12/6/2013 5:07:00 AM    

Hello David,
The View only creates root containers where dock panels are placed. This is a required step of creating the Docking UI.

Added By: David Lemieux at: 12/16/2013 2:00:09 PM    

Alex, I was refering to MainWindow.xaml.cs file. It has AddPanel_Click and AddDocument_Click methods, in which view models instances are created.

If the purpose of the example is to demonstrate how DX docking can be used with the MVVM pattern, then the DockLayoutManagerViewModel class should be responsible for creating / adding documents. Giving this responsibility to the view class goes straight against MVVM design rules, IMHO.

Added By: Alex Zeller (DevExpress) at: 12/17/2013 4:34:14 AM    

David, you're right. We have moved the code that creates Panels and Documents to View Models.

Added By: David Lemieux at: 12/17/2013 5:16:25 AM    

Thanks. You might want to clean up MainPage's code too. The DockLayoutManagerViewModel is instanciated in both the XAML and code behind. ;)

Added By: Raju Muthu at: 1/6/2014 12:04:12 PM    

Can this example extended to using PRISM regions? or is there an example already with this feature utilizing Prism?

Added By: Gagan Kapoor at: 2/1/2014 2:54:16 PM    

Hi, I need a dock UI with ability to host different types of views in Document Group (Tabs) at run time using Prism. Can you point me to an example of it ?

Added By: Michael Ch (DevExpress Support) at: 5/22/2015 12:15:40 AM    

Hello Raju and Gagan,

We accidentally discovered that your initial posts were out of scope of our Support Center for a long time. Please accept our sincere apologies for not responding in a timely manner.

We have few samples showing of how to use the DXDocking suite with the Prism framework. Below is a list of them. Please take a moment to review them and let us know if you have additional questions.
1. Using DXDocking for WPF in accordance with Composite Application Guidelines 
2. How to use the DXDocking and DXBars components with Prism 
3. Prism - How to define Prism regions for various DXDocking elements 

Thanks,
Michael

Viewing all 7205 articles
Browse latest View live


Latest Images

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