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

How to evaluate a customer acquisition using the quarter/year of their first purchase

$
0
0

This example shows how to evaluate a customer acquisition by grouping customers by the quarter/year of their first purchase to compare sales contributions. To learn more, see examples from the Intermediate Level Aggregations topic.


Getting Started - Creating an ASP.NET MVC Dashboard Designer Application (Runtime sample)

ASPxDashboard - How to save a dashboard state to cookies

$
0
0

The sample illustrates how to save the current ASPxDashboard state (such as master filter or parameter values) to cookies on the client side and restore this state on the server side. The following API is used in this example:
- The ASPxClientDashboard.DashboardStateChanged event is handled to obtain the current dashboard state.
- The ASPxClientUtils.SetCookie client-side method is used to save the dashboard state to cookies.
- In the ASPxDashboard.SetInitialDashboardState event handler, the dashboard state is loaded from the cookies and applied to a dashboard.

ASP.NET MVC Dashboard - How to provide data for ObjectDataSource using a fill service

ASP.NET MVC Dashboard - How to bind a dashboard to an Entity Framework Data Source

$
0
0

The following example shows how to add the Entity Framework data source to the Web Dashboard's list of data sources available to end-users. In this example, the DashboardEFDataSource class is used to establish a connection to the Entity Framework data source.

How to apply conditional formatting to Grid cells using the Bar Gradient Ranges condition

$
0
0

The Bar Gradient Ranges condition (FormatConditionGradientRangeBar) allows you to visualize numeric values using bars whose colors are contained in the specified color gradient.

This example shows how to apply conditional formatting to Grid cells using the predefined Red-Blue color gradient. Use the Update Formatting button to change start/end colors and the number of ranges in the color gradient. The third color in the middle of the color scale is also specified to generate a 3-color gradient.

WinForms Designer - How to customize the Data Source wizard for the OLAP data source

How to apply conditional formatting to Grid cells using the Bar Color Ranges condition

$
0
0

The Bar Color Ranges condition (FormatConditionColorRangeBar) allows you to visualize numeric values using bars whose colors are contained in the specified color set.

This example shows how to display colored bars within Grid cells. Use the Update Formatting button to change the number of ranges, specify new range boundaries and customize colors corresponding to existing ranges.


How to apply conditional formatting to Grid cells using the Top-Bottom/Average conditions

$
0
0

The Top-Bottom (FormatConditionTopBottom) format conditions allow you to highlight a specific number of topmost/bottommost values. This example shows how to apply conditional formatting to the specified number of top/bottom values. The number of values can be specified as an absolute value or a percentage of all values.
The Average format condition (FormatConditionAverage) is used to highlight values above or below an average value.

ASPxDashboard - How to pass a hidden dashboard parameter to a custom SQL query

$
0
0

The following example shows how to filter a custom SQL query by changing a parameter value in the ASPxDashboard.CustomParameters event handler.

In this example, the custIDQueryParameter query parameter is included in a WHERE clause of a custom SQL query. The custIDQueryParameter parameter is also bound to the hidden custIDDashboardParameter dashboard parameter. The value of this parameter is changed at runtime by handling the ASPxDashboard.CustomParameters event which is raised before the ASPxDashboard sends a query to a database.

How to obtain data from a Sparkline field corresponding to a selected row or card

$
0
0

Note: Starting with v17.1, we recommend using the ASPxDashboard control or a corresponding ASP.NET MVC extension to display dashboards within web applications.
 

The following example demonstrates how to obtain client data corresponding to a particular visual element using ASPxDashboardViewer's client-side API.

In this example, the ASPxClientDashboardViewer.ItemClick event is handled to obtain client data and invoke the dxPopup widget with the child dxChart.

In the event handler, the ASPxClientDashboardItemClickEventArgs.GetData method is called to obtain dashboard item's client data. The ASPxClientDashboardItemClickEventArgs.GetAxisPoint method returns the axis point corresponding to the clicked card while the ASPxClientDashboardItemData.GetSlice method returns the slice of client data by this axis point.
To obtain axis points belonging to the "Sparkline" data axis, the ASPxClientDashboardItemDataAxis.GetPoints method is used. Corresponding actual/target values are obtained using the ASPxClientDashboardItemData.GetDeltaValue method.

The dxChart is used to display the detailed chart showing a variation of actual/target values over time.

See Also:
T170990: How to retrieve last level data from Client Dashboard Item and display it using different ASP.NET controls
T182186: How to get visible data from a certain dashboard item on the client side and process it on the server side


How to provide custom summary values for Total, Grand Total and ordinary cells

$
0
0

This example demonstrates how to determine the value type when you calculate custom summary values.
1. Set the data field's SummaryType property to Custom to perform calculations manually, by handling the CustomSummary event. 
2. Use the PivotGridCustomSummaryEventArgs.ColumnField and PivotGridCustomSummaryEventArgs.RowField properties to determine the kind of a processed cell. You can use the following rules to determine that a cell is being processed:

    a. If ColumnField or RowField is null, it means that this is a Grand Total cell;
    b. If both ColumnField and RowField are last fields in a corresponding area, this means that this is an ordinary cell.
    c. In other cases, this is a Total cell.


See Also
T158425: How to calculate Total cell values based on the low level Cell summary values

Example versions for other platforms:

E2592: How to provide custom summary values for Total, Grand Total and ordinary cells for ASPxPivotGrid
T555636: How to provide custom summary values for Total, Grand Total and ordinary cells for WPF PivotGridControl

Getting Started - Create an ASP.NET Core Dashboard Designer (Runtime sample)

How to implement T-SQL language syntax highlighting by creating Syntax Highlight Tokens

$
0
0

This example illustrates how to implement simplified syntax highlighting for the T-SQL language by registering the ISyntaxHighlightService. Note that we do not use the DevExpress.CodeParser library in this example. Text is parsed into tokens (a list of SyntaxHighlightToken Class instances) manually in the CustomSyntaxHighlightService.ParseTokens() method. The resulting list is sorted (see Documentation - It is not mentioned that a list passed to the SubDocument.ApplySyntaxHighlight method should be sorted) and passed to the SubDocument.ApplySyntaxHighlight Method.

See Also:
Syntax highlighting for C# and VB code using DevExpress CodeParser and Syntax Highlight tokens - Syntax highlighting for C# and VB code using DevExpress CodeParser and Syntax Highlight tokens

Question Comments

Added By: Roland Radlmair at: 6/6/2013 1:35:59 AM    

Hi,

could you also add the functionality for highlighting comments like "// this is a comment".

That would be great!
Thanks.

Added By: Martijn Loeffen at: 3/3/2014 8:32:11 AM    

This example throws an exception when running with DevExpress 2013.1.9 and 2013.2.7. A workaround is to replace the order of the folowing lines:

richEditControl1.ReplaceService<ISyntaxHighlightService>(new CustomSyntaxHighlightService(richEditControl1.Document));
richEditControl1.LoadDocument("CarsXtraScheduling.sql");

There still remains an issue, because another document cannot be loaded: it still throws an exception.

Added By: Anders Wang at: 6/25/2015 8:47:48 PM    

public void Execute() {
           document.ApplySyntaxHighlight(ParseTokens());
       }

Hi,
it is not so correct way to call ParseTokens() each time when need ApplySyntaxHighlight. You can try it with increase the keywords array to above 200-500. The tokens should be initialized when the docment loaded. After then, it should be updated incrementally and should not be build each time.

Added By: Andrey (DevExpress Support) at: 6/26/2015 5:25:32 AM    

Hello,
I have discussed this behavior with our developers and we have come to the conclusion that this behavior is by design.
For now, we are not planning to change it in the near future.

Added By: Stephan Stauber at: 7/29/2015 7:25:58 AM    

Instead of
// search for quotation marks
ranges = document.FindAll("'", SearchOptions.None);
for (int i = 0; i < ranges.Length / 2; i++) {
tokens.Add(new SyntaxHighlightToken(ranges[i * 2].Start.ToInt(),
ranges[i * 2 + 1].Start.ToInt() - ranges[i * 2].Start.ToInt() + 1, stringSettings));

it's better to use a Regex, especially if you want to highlight "double quoted strings" as well as 'single quoted strings'. We tried to search first for all single quotes and then for double quotes. not a good idea.
We had many errors, when a quotation was not ended (open quote exists without end quote) inside another quote (i.e. "this's a quote, "where "single 'quote' is not closed")

...
stringRegex = new Regex(@"((""(.|/[[:blank:]]/)*?"")|('(.|/[[:blank:]]/)*?'))"); //original pattern: (("(.|/[[:blank:]]/)*?")|('(.|/[[:blank:]]/)*?'))
...
// search for quoted strings
ranges = document.FindAll(stringRegex);
foreach (var range in ranges)
tokens.Add(new SyntaxHighlightToken(range.Start.ToInt(), range.Length, stringSettings));

Added By: Oleg (DevExpress Support) at: 7/29/2015 7:44:46 AM    

Thank you Stephan for sharing your approach here and especially for posting your regular expression.

Added By: Marc Trudel at: 6/14/2017 3:17:33 PM    Hi
Do you have a newer version of this that supports comments ?

-- and /* */ highlighted in green as in SSMS

Thank you Added By: Ingvar (DevExpress Support) at: 6/15/2017 3:30:19 AM    

Hi Marc,

This example illustrates how to apply syntax highlighting using custom rules (in this case, for basic constructions available in T-SQL). I.e., this example is not intended to fully support all T-SQL constructions, but to demonstrate how to handle different text elements. If you look at the ParseTokens method, you will see that the document is parsed manually in order to locate required parts (string entries and keywords). You can implement a similar search mechanism for comments and add required tokens to the output collection. To sum it up, all you need to do is to locate "comment" ranges using the Document.FindAll method and create SyntaxHighlightTokens for them. If you encounter any difficulties implementing this approach, please create a separate ticket and provide us with a sample project demonstrating the actual result. We will guide you on how to overcome these difficulties.

How to print/export only records that are checked by XRCheckBox in the detail band

$
0
0

This example demonstrates how to conditionally include rows into a printed/exported web report. To select rows, the XRCheckBox is used. Once the user clicks on the corresponding XRCheckBox, the client script is executed (it is defined via the XRCheckBox.NavigateUrl property within the XRCheckBox.BeforePrint event handler), and a callback is sent to the server to update the internal storage (in the Session variable) of the skipped rows and regenerate a report in the ReportViewer accordingly.

Note that by inspecting the Page.Request["__EVENTARGUMENT"] parameter, you can determine whether the print/export command is initiated via the ReportToolbar button. If so, you should handle the XRControl.BeforePrint event for the DetailBand and XRCheckBox, and set the e.Cancel parameter to true based on your logic to skip unnecessary report content elements.


Navigation - Implementing callback-based navigation in the Template Gallery-based project

$
0
0
Problem:

I created a new MVC application by using the ASP.NET MVC Web Application template from the Template Gallery (see also: Project Wizard). After that, I added several custom partial views and want to load them dynamically when an end-user clicks a specific item of the NavBar extension in the ContentLeftPartialView.cshtml partial view. What should I do?


Solution:
Here are the most straightforward approaches to solving this problem:

1) Load the required partial views via  the jQuery.ajax function by using the approach illustrated in the E4063 - How to use the jQuery.ajax function with DevExpress MVC Extensions code example. 

2) Or, use our CallbackPanel extension and the MVCxClientCallbackPanel.PerformCallback(Object) method.

In both scenarios, you need to handle the client-side ASPxClientNavBar.ItemClick event and initiate a parametrized callback (ajax or CallbackPanel-specific) to the appropriate controller's action method on the server side and get the required partial view.

Note that if you are working with regular (full) views instead of partial views, follow the approaches described in the KA18732 - How to open external Page / View in a Splitter Pane KB article and examples linked to this article.

See Also:
KA18923 - The SetContent method - How to define a content using different syntax constructions
Menu - How to load a content using callbacks on a menu item click based on the DevExpress Project template

DXRichEdit - How to invoke RichEditControl API from the client script and vice versa

$
0
0

To invoke RichEditControl API from the client script, do the following:

1) Register a managed Silverlight page object for scriptable access from JavaScript code as follows:

[C#]
publicpartialclassMainPage:UserControl{publicMainPage(){InitializeComponent();HtmlPage.RegisterScriptableObject("skPage",this);}...

2) Add the managed method you wish to call from your JavaScript code. You must prefix it with the [ScriptableMember] attribute:

[C#]
[ScriptableMember()]publicvoidRichEditCreate(){richEditControl1.CreateNewDocument();}

3) In JavaScript, you can now call directly to your Silverlight function. This can be done through the document object:

[JavaScript]
var host = document.getElementById('silverlightPlugIn'); host.Content.skPage.RichEditCreate();

where 'silverlightPlugIn' is the ID of the Silverlight plug-in in the hosting page.


To invoke the client script function from the Silverlight code, you just need to call the HtmlPage.Window.Invoke() method with the specified JavaScript function name:

        

[C#]
HtmlPage.Window.Invoke("showText",richEditControl1.Text);
[JavaScript]
function showText(text){ alert(text);}

The sample application is illustrated in the screenshot below.

Note: Not all RichEditControl functionality can be activated from JavaScript. For instance, the RichEditControl.LoadDocument Method call will fail because of the corresponding Silverlight platform restriction (see the Call OpenFileDialog Silverlight from JavaScript webpage).

See Also:
Silverlight Tip of the Day #15 – Communicating between JavaScript & Silverlight

DXRichEdit - How to force images from external hosts to be loaded into RichEditControl

$
0
0

By default, Silverlight application connectivity is limited to the host or site of origin. This means that a web application can only communicate back to its deploying server, so network applications ere allowed to connect to the host from which they were downloaded. This nuance is specific to the Silverlight platform and can be resolved by adding an appropriate "clientaccesspolicy.xml" file to the root of the requested target domain (see Network Security Access Restrictions in Silverlight). We are using this solution (which appears to be the simplest one) in our scenario.


Here is the projects structure of our example:


SLApplication - Silverlight application

SLApplication.Web - ASP.NET Web Site where the Silverlight application is hosted.

ExternalWebSite - This ASP.NET Web Site simulates a remote host where the image (\Images\devexpresslogo.png) requested by the Silverlight application is placed


Note that the "clientaccesspolicy.xml" file is located at the root of the ExternalWebSite.


The HTML file from which the remote image is referenced is placed in the host of origin (SLApplication.Web). Here is how it is loaded into the RichEditControl:


[C#]
WebClientwebClient=newWebClient();webClient.OpenReadCompleted+=newOpenReadCompletedEventHandler(webClient_OpenReadCompleted);webClient.OpenReadAsync(newUri("http://localhost:1046/SLApplication.Web/TestPage.html",UriKind.Absolute));...voidwebClient_OpenReadCompleted(objectsender,OpenReadCompletedEventArgse){if(e.Error==null){richEditControl1.ApplyTemplate();richEditControl1.LoadDocument(e.Result,DocumentFormat.Html);}}

Note:

This approach can be used only when you have access to the remote host or can ask its administrator to configure it to allow cross-domain access.


See Also:

WebClient Class

Create an appointment for each selected resource instead of a multi-resource appointment

$
0
0

This approach can be used if you want to create several appointment copies instead of creating a multi-resource appointment when shared resources mode is used (see"Assigning Appointments to Resources" section in the Resources for Appointments help article). Also, you can simulate this mode i. e. you are not using shared resources in your application but simulate its usage with the approach described in this example.

The key idea of this approach is to create a custom appointment form (see How to: Create a Custom EditAppointment Form with Custom Fields) with AppointmentResourcesEdit and define the following logic for it:

[C#]
publicCustomAppointmentForm(SchedulerControlcontrol,Appointmentapt,boolopenRecurrenceForm){...this.edResources.SchedulerControl=control;}voidUpdateForm(){SuspendUpdate();try{...edResources.ResourceIds.Clear();edResources.ResourceIds.Add(controller.ResourceId);}finally{ResumeUpdate();}UpdateIntervalControls();}privatevoidbtnOK_Click(objectsender,System.EventArgse){...controller.ResourceId=edResources.ResourceIds[0];controller.ApplyChanges();foreach(objectiteminedResources.ResourceIds){if(item.Equals(controller.ResourceId))continue;Appointmentapt=controller.EditedAppointmentCopy.Copy();apt.ResourceId=item;control.Storage.Appointments.Add(apt);}}

Note that we are using the Appointment.Copy Method to create appointment copies. This method works as required for appointment types that can be created via appointment form (Normal and Pattern).

Using RichEdit converters to bind a RichEditControl to a particular entity and vice versa

$
0
0

This example illustrates how to use SpecificFormatToContentConverter and ContentToSpecificFormatConverter to setup binding between RichEditControl content and other DependencyProperty of a specific DependencyObject (TextBox in this example). The main window UI is composed in a special manner to clearly illustrate that you should utilize SpecificFormatToContentConverter if you wish to bind RichEditControl.Content property to a specific entity property. Otherwise, if you wish to bind a specific entity property to a RichEditControl.Content property, utilize ContentToSpecificFormatConverter. Here is the corresponding screenshot:

We have used OneWay binding mode (data is transfered from source to target) in this example for clarity sake. Please review the following web pages to learn more about other available binding modes and general WPF data binding concept:

Data Binding in WPF
Data Binding Overview

See Also:
DXRichEdit for WPF: How to establish data binding for the RichEditControl to bind text in different formats

Question Comments

Added By: Itamar Shoham at: 7/3/2016 1:50:56 PM    notice, in Version 15.1 I'm getting the following error message:
'The member "ActiveViewType" is not recognized or is not accessible'

while this page - https://documentation.devexpress.com/#WPF/DevExpressXpfRichEditRichEditControl_ActiveViewTypetopic
states that the member has getter and a setter.

Added By: Mariya (DevExpress Support) at: 7/4/2016 1:12:12 AM    

Hello,

I've created a separate ticket on your behalf (T399248: The member "ActiveViewType" is not recognized or is not accessible). It has been placed in our processing queue and will be answered shortly.

Viewing all 7205 articles
Browse latest View live