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

How to register and use SVG shapes

$
0
0

This example demonstrates how to register and use SVG shapes in DiagramControl. The ShapeDescription.CreateSvgShape method creates a shape from a stream that contains an SVG image.

Icons used in the sample project: IcoMoon's "Free Shapes" pack.


How to implement a seat reservation functionality

$
0
0
The sample illustrates how to create a seat reservation functionality using the Table control with Label controls and ASPxCallbackPanel.

1. Create various css classes to assign them to a Label control  depending on  a seat status. The Page css style includes three classes:
the free css class is applied to Label if a seat is free;
the selected css class is applied to Label that is clicked by user;
the reserved css class is applied to Label if a seat is reserved;

2. Implement the Seat class with IsFree and Text properties. IsFree returns true if a seat is free and false if it’s reserved. Text returns a number of a seat. Create a collection of Seat objects to present a full list of seats.

3. For every Seat object from the collection, generate a Label control in the Table control. Depending on the Seat.IsFree property, assign the necessary css class to the Label.

4. To process clicked Label controls, subscribe to the Label client onclick event. Do it in the Label.Init event handler to pass the final ClientID as a function parameter.

5. On the client side, add the selected element id to a javascript array. When the Reserve button is clicked, call the ASPxClientCallbackPanel.PerformCallback and pass that collection to the server.

6. In the ASPxCallbackPanel.Callback event handler,  iterate the passed collection and change the Seat.IsFree property to false for necessary Seat objects of the List<Seat> collection. Recreate the Table control.

How to save GridColumns' width values to cookies and restore them

$
0
0

ASPxGridView control doesn't send a callback to the server when a GridColumn width is changed. GridColumns' width value will be passed to the server with the next ASPxGridView callback. If a callback is not sent, page reloading will cause losing columns' new widths. The sample illustrates how to save ASPxGridView columns' widths to a cookie at the client side and apply them at the server side. 

Note that the SettingsCookies.StoreColumnsWidth property should be assigned to False to disable overwriting our GridColumns' width by default GridColumns' width saved with the help of SaveClientLayout.

How to show a border around a focused editor

$
0
0

This example shows the way to change the visual appearance of a focused editor.

Let's assume that the editor must show an additional border when focused.

To create this feature, it's necessary to create a custom template and place a new border element there, which will be displayed every time the control is focused. There is a template "WPFEditorsFocusFrame" in the resource dictionary in which rectangle named "FocusFrame" is defined. This rectangle is playing the role of the focus border, and it's Visibility property is bound to the IsKeyboardFocusWithin property of the control.

The described template is general for several DXEditors types and is applied automatically to TextEdit, PasswordBoxEdit, ButtonEdit, ComboBoxEdit, LookupEdit and other button-based editors. So, once you define this template, you'll get the same behavior for all of these controls.

Starting with version 16.1, we changed our templates and introduced the new default theme - Office2016White. So, you need to use the HoverBorderTemplate resource to accomplish this task.

How to preserve the expanded state of TreeList nodes when refreshing data

$
0
0

The example contains a helper class that can be used to save and load the current expanded / collapsed state of the XtraTreeList nodes. Please refer to How to preserve the expanded state of TreeList nodes when refreshing data article to learn more.

Question Comments

Added By: Peppomuck at: 7/14/2013 8:09:46 AM    

Why don't you save the node.Id's in a List<int> ?
That would be more type safe (instead of seraching by node.GetValue(node.TreeList.KeyFieldName) and safing object types in ArrayList)
Besides, your example doesn't match when you reassign (e.g. after saving and reloading data) the binding source or the KeyFieldName doesn't expect like in the example.

Added By: Trent Jones at: 2/25/2015 11:17:09 PM    

Is there a chance of this being implemented to the XtraTreeList Suite? I can imagine there are large amounts of people who use this code regularly.

Added By: Olejka (DevExpress Support) at: 2/26/2015 4:29:09 AM    

Hello,

Currently, we don't have plans to implement this option out of the box. We've implemented this solution to allow our users to manually save nodes' state. 
Nevertheless, thank you for your input. We will consider implementation of this feature in the future.

Added By: alvin johnson 1 at: 2/18/2016 11:44:05 AM    Hello Olejka,

I have used this class to save the state of treelist. On save button click I have initialized XView and TreeStateView(TreeList) classes. And after that I am calling the method SaveState(). But it never shows any expanded and selected nodes.

Am I doing something wrong?

After this I want to serialize these expanded and selected properties to load this treelist state.

Please give me the solution.
Added By: Nadezhda (DevExpress Support) at: 2/18/2016 2:35:43 PM    

Hello alvin,

To process your recent post more efficiently, I created a separate ticket on your behalf: How to save state after update. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Pavel Voinov at: 4/13/2017 8:10:35 AM    Hello,
Where i can find TreeListViewState class?Added By: Pavel (DevExpress Support) at: 4/13/2017 12:19:28 PM    

Hello,

I've created a separate ticket on your behalf (T503999: TreeList - where to find the TreeListViewState class?). It has been placed in our processing queue and will be answered shortly.

Drag & Drop in TreeList and GridControl - How to show dragged rows as a cursor

$
0
0

This example shows how to customize drag&drop in Grid and TreeList controls, so that a dragged row is shown as a cursor. To do so, you need to override the corresponding DragDropManager class to pass RowData to DragElement instead of the row content and change its template to draw rows in the same way as they are drawn in Grid.

Question Comments

Added By: Mikhail Shubin [DevExpress MVP] at: 9/22/2015 12:00:11 PM    

Nice solution!

Added By: Berk Yazicioglu at: 4/13/2017 3:44:40 PM    How can I show a red background on places that I cannot drop the dragged row?

ImageSlider Virtual Mode

$
0
0

This example demonstrates the ImageSlider control running in the Virtual Mode.

Question Comments

Added By: Ron Blakemore 2 at: 4/14/2017 12:19:06 AM    Why do you never show a complete demo/example

I need to load the images from a set path/folder

But How do you do that with this example Added By: Alisher (DevExpress Support) at: 4/14/2017 2:07:31 AM    Hi Ron,

A complete demo can be downloaded by clicking the Example link in the Downloads panels available at the right side of the page. Please check it.
If you want to load images from a particular folder, modify the example in the following manner. Initialize the images variable in the Form's constructor with a list of paths to your images by using the Directory.GetFiles method. Once the variable is initialized, modify the GetImage event handler as follows:
[C#]
privatevoidimageSlider1_GetImage(objectsender,DevExpress.XtraEditors.Controls.GetImageEventArgse){if(e.IsStartUp){e.Image=Image.FromFile(images[0]);return;}if(e.IsNext){e.Image=Image.FromFileimages[currentImageIndex+ 1]);if(e.CurrentImageUpdated)++currentImageIndex;}elseif(e.IsPrev){e.Image=Image.FromFileimages[currentImageIndex- 1]);if(e.CurrentImageUpdated)--currentImageIndex;}}
Let me know if you have additional questions.

MVC Dashboard - How to implement the Save As and Delete functionality by creating custom extensions

$
0
0

This example demonstrates how to add the "Save As" and "Delete" options to the MVC Dashboard control.
It requires only a few changes to utilize the solution described in the T466716: Web Dashboard - How to work with extensions article in MVC:

1. Use the SetDashboardStorage method to define the default storage:

[C#]
protectedvoidApplication_Start(){...DashboardConfigurator.Default.SetDashboardStorage(newDashboardFileStorage(Server.MapPath("~/App_Data/Dashboards")));

 

2. Handle the client-side Init event using the DashboardExtensionSettings.ClientSideEvents property:

[C#]
@Html.DevExpress().Dashboard(settings=>{settings.Name="Dashboard";settings.ClientSideEvents.Init="onInit";}).GetHtml()

 

3. Define a controller action that should be used to delete dashboards:

[C#]
publicActionResultDeleteDashboard(stringDashboardID){   CustomDashboardFileStoragenewDashboardStorage=newCustomDashboardFileStorage(@"~/App_Data/Dashboards");   newDashboardStorage.DeleteDashboard(DashboardID);   returnnewEmptyResult();}


4. Customize the DeleteDashboardExtension.deleteDashboard function to call the server-side DeleteDashboard action using AJAX:

[JavaScript]
this.deleteDashboard = function(){var dashboardid = _this._designer.dashboardContainer().id; $.ajax({ url: 'Home/DeleteDashboard', data: { DashboardID: dashboardid}, type: 'POST',}).success(function(){ _this._designer.close();});}

 


How to preserve the Legend checkbox item state in an ASP.NET MVC application

$
0
0
Chart extension does not cache information about the Series item state when the Legend checkbox feature is enabled. In this situation, it is required to handle the ChartControlSettings.BoundDataChanged event to restore the Legend item checkbox state. This example illustrates how to save the Legend state into a Session variable using the ChartControlSettings.LegendItemChecked event and then restore it on subsequent page requests.

See also:

How to preserve the Legend checkbox item state when the Series collection is initialized programmatically;
How to preserve the Legend checkbox item state when the Series Template approach is used to generate the Series collection.

How to preserve the Legend checkbox item state when the Series collection is initialized programmatically

$
0
0

WebChartControl does not cache information about Series items and data source initialized at runtime. As a result, the Legend item checkbox state cannot be applied correctly. This example illustrates how to save the Legend state into a Session variable and restore it using the Page_Load event handler. The WebChartControl.LegendItemChecked event is used to obtain the current Legend panel state. Note that it is also required to disable the internal viewstate management using the WebChartControl.EnableViewState and WebChartControl.SaveStateOnCallbacks properties.

See also:

How to preserve the Legend checkbox item state when the Series Template approach is used to generate the Series collection;
How to preserve the Legend checkbox item state in an ASP.NET MVC application.

How to preserve the Legend checkbox item state when the Series Template approach is used to generate the Series collection

$
0
0
WebChartControl does not cache information about auto-generated Series when the Series Template approach is used to initialize the chart layout. In this situation, it is required to handle the WebChartControl.BoundDataChanged event to restore the Legend item checkbox state. This example illustrates how to save the Legend state into a Session variable using the WebChartControl.LegendItemChecked event and then restore it on subsequent page requests.

See also:

How to preserve the Legend checkbox item state when the Series collection is initialized programmatically
How to preserve the Legend checkbox item state in an ASP.NET MVC application.

How to display both marker image and check box element in the legend panel

How to implement a Theme Selector control similar to DevExpress Demo ThemeSelector web user control

$
0
0

The sample provides a web user control(ThemeSelector) that can be used in your project. To use this control in your solution, execute these steps:

1. Copy following files, taking into account their location:

   a. an xml file with theme groups and themes: Themes.xml.

   b. classes that are responsible for getting and presenting data from Themes.xml: ThemeGroupModel.cs, ThemeModel.cs, ThemeModelBase.cs, ThemesModel.cs.

   c. Sprite.png with images.

   d. ThemeSelector.css with css classes.

   e. ThemeSelector.ascx and ThemeSelector.ascx.cs.

2. Register the ThemeSelector web user control in your web.config file:

[ASPx]
<pages><controls><addsrc="~/UserControl/ThemeSelector.ascx"tagName="ThemeSelector"tagPrefix="dx"/></controls></pages>

3. In the sample, a chosen theme is written to a cookie. To apply this theme from the cookie, subscribe to the Application.PreRequestHandlerExecute in your Global.asax file and handle it

in the following manner:

[C#]
protectedvoidApplication_PreRequestHandlerExecute(objectsender,EventArgse){if(Request.Cookies["CurrentThemeCookieKey"]!=null){DevExpress.Web.ASPxWebControl.GlobalTheme=Request.Cookies["CurrentThemeCookieKey"].Value;}}

4. The ThemeSelector control allows you to show a popup left or right relative to the "Themes" anchor. Use the ThemeSelector.PopupAlign property. The default value is PopupAlign.Right.

[ASPx]
<dx:ThemeSelectorrunat="server"ID="ts2"PopupAlign="Left"/>

How to draw a horizontal line indicating current time

$
0
0

Starting from v15.2, our SchedulerControl can now indicate the current time by drawing a line in the view out-of-the-box. In the Day, Work-Week, and Full Week views, the horizontal line can go across the entire view, or it can be restricted to the current date. See the DevExpress Scheduler controls: big changes are coming in v15.2 blog for more details. To customize the default Time Indicator painting, use the SchedulerControl.CustomDrawTimeIndicator event.


For versions older than 15.2, use the CustomDrawTimeCell event to draw a horizontal line across the scheduler indicating the current time in the Day and WorkWeek views.

Question Comments

Added By: Magnat at: 8/12/2013 4:41:38 AM    

Do you have a sample which works with WPF?

Added By: FieldAssist Development at: 9/25/2013 2:30:29 AM    

Do you have a sample to draw a vertical line in the timeline view ?

How to custom-draw the Current Time Marker


ASPxGridView - Editing an in-memory dataset

$
0
0

This example is an illustration of the KA18686: ASPxGridView - How to implement CRUD operations with a custom data source KB Article. Refer to the Article for an explanation.

See Also:
How to insert, edit and delete data in a data table by ASPxGridView at runtime

Question Comments

Added By: Wayne Stoner at: 12/15/2015 7:59:20 AM    

This example isn't showing any of the code-behind.

Added By: Helen (DevExpress Support) at: 12/15/2015 9:53:42 AM    

Hello,

I tried to open the example on my side and it displays the code behind for all versions, both VB.NET and C#. See the video. Try to reload the page by pressing Ctrl+F5 and check the example again. If the problem persists, specify your browser family and version. 

Added By: Nir Dagan 1 at: 5/25/2016 9:17:55 PM    This example is what i was looking for.
there is one interesting part missing:
ShowNewButton="True" for the DetailRow

i wonder how can that be implemented

Added By: Alessandro (DevExpress Support) at: 5/25/2016 11:30:43 PM    

Hello,

I've created a separate ticket on your behalf (T384038: E257: Editing an in-memory dataset). It has been placed in our processing queue and will be answered shortly.

Added By: Petar Kosama at: 11/21/2016 5:28:32 AM    Regarding this tutorial, how I am able to show a message popup if some of the input data is invalid? 

I have already created a popup and I want to do something like:

[C#]
protectedvoidgrid_RowUpdating(objectsender,DevExpress.Web.Data.ASPxDataUpdatingEventArgse){vartext=myTextBox.Text;if(string.IsNullOrEmpty(text)){MyMessageBox.Show(textNummer);e.Cancel=true;}else{grid.CancelEdit();e.Cancel=true;}}
The problem is that the popup is not shown if there is 
[C#]
e.Cancel=true;
Otherwise I get an exception if I don't set e.Cancel = true.

Thanks
Added By: Lex (DevExpress Support) at: 11/21/2016 8:26:37 AM    

Hello Petar,

I've created a separate ticket on your behalf (T453130: ASPxGridView - Batch Edit - How to show a message if data is invalid). It has been placed in our processing queue and will be answered shortly.

How to get a list of DevExpress themes and apply them to an application

$
0
0

In the sample, a web UserControl is created, which allows you to do the following:
 

1. Get all DevExpress themes' names.

2. Choose what control (ASPxComboBox, ASPxMenu) to use for showing theme names. Use the UserControl.ControlType property.

3. Choose a request method(GET,POST) to reload a page and apply a new theme. Use the UserControl.RequestMethod property. 


The selected theme is written to a cookie. The cookie value is got and applied in the Application.PreRequestHandlerExecute event handler.

XtraCharts Web Toolbar

$
0
0

The following example demonstrates how to create a toolbar similar to the one available in the XtraCharts Web Demo. This toolbar allows you to print a WebChartControl, export it to various formats (PDF, XLS, PNG, JPEG, BMP, TIFF, GIF), as well as change its palette and appearance.

NOTE: To be able to use this toolbar in your application, you need to have a license for the ASPxEditors assembly.

Question Comments

Added By: Saket Nalegaonkar at: 9/1/2015 4:34:14 AM    

I need it's implementation with v14.2 . Really really urgent.
Also would be glad if you could elaborate<SeriesSerializable> tag.

Added By: John (DevExpress Support) at: 9/1/2015 4:49:55 AM    Hi Saket,
I have created a separate ticket for this your question: Create XtraCharts Web Toolbar. Let's continue the conversation there.

Added By: h biglibigli at: 4/17/2017 6:12:45 AM    Hi, and thanks for this example. but how can I set print option like landscape for chart ? print method is in javascript and as I know I must use PrintableComponentLink for this Added By: Sergi (DevExpress Support) at: 4/17/2017 7:52:16 AM    

Hello,

I've created a separate ticket on your behalf (T504847: WebChartControl - How to set Landscape printing mode). It has been placed in our processing queue and will be answered shortly.

How to: Use the WizardService

How to use NavBarControl with Prism

$
0
0

This example demonstrates how to add groups to NavBarControl using PRISM. See the Implementation Details section to learn more on how to enable PRISM support in the selected DevExpress version.

Viewing all 7205 articles
Browse latest View live


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