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

ASPxRichEdit - How to define the default page settings such as margins, paper kind, landscape etc

$
0
0

It's possible to use the non-visual RichEditDocumentServer component to adjust the required document settings. Create a new document using RichEditDocumentServer and adjust its page by using the corresponding API.
Refer to the following documentation articles, where you can learn how to set the required properties:

Document 
DefaultCharacterProperties

This example demonstrates how to set a document page's landscape, paper kind, margins and font properties.


How to show images in the CheckedComboBoxEdit edit box and its dropdown window

$
0
0

This examples demonstrates how to display images in the CheckedComboBoxEdit edit box and its dropdown window when the editor is used in bound mode. This task is accomplished at an editor descendant level.

To show images in the dropdown window, it is necessary to set the RepositoryItemCheckedImageComboBoxEdit.ImageMember property to a column name whose values represent Image objects or a byte array. If you wish to display these images in the edit box, you should also set the RepositoryItemCheckedImageComboBoxEdit.ShowImagesInEditBox property to true.

Question Comments

Added By: Michael Osborne at: 12/2/2016 7:27:22 AM    Once I have this editor, how do I assign images to it?Added By: Alisher (DevExpress Support) at: 12/2/2016 7:47:41 AM    Hi Michael,

As noted in the description, to show images in the dropdown window, it is necessary to set the RepositoryItemCheckedImageComboBoxEdit.ImageMember property to a column name whose values represent Image objects or a byte array. Have you set this property?Added By: Luka Lovre at: 5/31/2017 6:02:50 AM    Does this allow me to have text and images in the same row?

How to use DashboardExtractDataSource in the ASPxDashboard control

$
0
0

This example demonstrates basic approaches and code snippets that can be used to add a DashboardExtractDataSource to the ASPxDashboard control. The Extract data source is often used if it requires a lot of time to request data from a database using a complex query or a stored procedure. The DashboardExtractDataSource allows you to request this data once and save it in the compressed and optimized form to a file. Then it will be possible to load data from this file and prepare a new file version when data is updated. This concept is described in the Faster Dashboards with the “Data Extract” Source blog.


The following code snippet is used to create a DashboardExtractDataSource and connect it to a DashboardSqlDataSource. Note that I use the CommandTimeout property to increase the query timeout:

[C#]
DashboardSqlDataSourcenwindDataSource=newDashboardSqlDataSource("Northwind Invoices","nwindConnection");SelectQueryinvoicesQuery=SelectQueryFluentBuilder.AddTable("Invoices").SelectColumns("Customers.CompanyName","Address","City","Region","PostalCode","Country","Salesperson","OrderDate","Shippers.CompanyName","ProductName","UnitPrice","Quantity","Discount","ExtendedPrice","Freight").Build("Invoices");nwindDataSource.Queries.Add(invoicesQuery);nwindDataSource.ConnectionOptions.CommandTimeout= 600;DashboardExtractDataSourceextractDataSource=newDashboardExtractDataSource("Invoices Extract Data Source");extractDataSource.FileName=GetExtractFileName(path);extractDataSource.ExtractSourceOptions.DataSource=nwindDataSource;extractDataSource.ExtractSourceOptions.DataMember="Invoices";

 

To add the data source to the ASPxDashboard control use the solution described in the Register Default Data Sources help topic:

[C#]
DataSourceInMemoryStoragedataSourceStorage=newDataSourceInMemoryStorage();dataSourceStorage.RegisterDataSource("extractDataSource",GetExtractDataSource(path).SaveToXml());ASPxDashboard1.SetDataSourceStorage(dataSourceStorage);

 

The UpdateExtractDataSource method is used to extract data from a database. Note that it is impossible to update a used file, thus a new file is always created:

[C#]
vards=GetExtractDataSource(path);stringfileName=DateTime.Now.ToString(extractFileName);ds.FileName=path+"Temp\\"+fileName;ds.UpdateExtractFile();

In this example, data is extracted on a button click. However, in a real-life application, this solution can be insufficient (e.g. the site may be deployed to the web farm server). We recommend creating a separate windows service that should update data automatically every hour or every day.

At last, the ConfigureDataConnection event is used to connect the data source to the latest file version:

[C#]
protectedvoidASPxDashboard1_ConfigureDataConnection(objectsender,ConfigureDataConnectionWebEventArgse){   ExtractDataSourceConnectionParametersextractCP=e.ConnectionParametersasExtractDataSourceConnectionParameters;   if(extractCP!=null){       extractCP.FileName=...;   }}

 

Question Comments

Added By: Tarun Susarapu at: 5/31/2017 6:29:56 AM    Hi,

I have created the 6 data extracts for loading 12 dashboards in my project using MVC.

I want to update that data extracts on initial loading of dashboard on my web page.

For that I have written one method and called at session_start event in global.asax.cs.

Here I used Tab control for loading 12 dashboards.

But it takes 2 minutes on page loading.

I want to reduce that time but the data extracts should be updated.

Please suggest me the best solution.

  protected void UpdateExtract(string dashboardId)
        {
            try
            {
                using (Dashboard newDashboard = new Dashboard())
                {
                        newDashboard.LoadFromXml(Server.MapPath(string.Format(@"~/App_Data/Dashboards/{0}.xml", dashboardId)));
                        var dataSources = newDashboard.DataSources.OfType<DashboardExtractDataSource>().ToArray();
                        foreach (DashboardExtractDataSource dataSource in dataSources)
                        {
                            dataSource.UpdateExtractFile();
                        }
                    //}
                  
                }
            }
            catch (Exception Ex) { }
        }


BootstrapGridView - Batch Edit mode - How to edit CheckBox column in a single click

$
0
0

At the moment, BootstrapGridView displays cells in CheckBox columns as images which makes it impossible to edit these cells in a single click. First, you have to click the cell to enter the edit mode and the second click actually changes the value. It is not very convenient, so we created a workaround that allows editing such columns in a single click.

For this, define a data item template for the CheckBox column and place an actual check box there. Synchronize this check box with the item collection - obtain the value using the Eval (or Bind) method and set a new value with SetCellValue.

Web Dashboard - How to save/load the custom data to/from the dashboard XML definition

$
0
0

This example demonstrates how to save the custom data related to a dashboard to the dashboard XML definition and how to load this data later. In this example, the standard 'Save' menu item removed from the Web Dashboard menu. A new 'Save As' menu item allows end-users to add a custom comment appended to the dashboard XML definition. Moreover, the current dashboard state and modified date is added to the XML definition. 

You can load dashboards containing custom data using the 'Open' menu item. A comment and modified date form the selected dashboard is displayed within the form at the top of the web page. The loaded dashboard state is applied to the dashboard using a client-side API.
The following API is used to implement these capabilities:
- The ASPxClientDashboard.GetDashboardControl method is called within the ASPxClientDashboard.BeforeRender event handler to customize the standard Web Dashboard menu.
- The ASPxClientDashboard.PerformDataCallback client-side method is used to pass the custom data to the server side. On the server side, the ASPxDashboard.CustomDataCallback event is used to obtain and parse these values. These values are saved to the dashboard XML definition using the Dashboard.UserData property.
- The ASPxDashboard.DashboardLoading event is handled to obtain the custom data from the UserData element when loading a dashboard.
- The ASPxDashboard.CustomJSProperties server-side event is used to pass the custom data obtained to the client side.
- The ASPxClientDashboard.DashboardChanged event is handled to display custom data related to the selected dashboard. Moreover, the SetDashboardState method applies the dashboard state.

How to bind a grid column to a referenced object's property when using XPO as a data source

$
0
0

Let's assume that there are Person and Address persistent objects. The Person class has an Address property of type Address. The Address class has a City column. The grid is bound to XpoDataSource with persons. The task is to display the Address.City value in a grid column. The solution is to set the grid column's FieldName to "Address.City".

See Also:
How to define a lookup column in the ASPxGridView bound to XpoDataSource

Question Comments

Added By: Pallavi Praharaj at: 6/1/2017 12:52:44 AM    This is a nice example. I am implementing the same but unable to bind the data in the grid view. In grid, I am getting the number of rows that should come but all values are empty. Am I missing something? 

How to calculate summary using summary values calculated by other columns

$
0
0

Within the GridView.CustomSummaryCalculate event handler, it's impossible to access a total summary calculated against another column. The total summary can be obtained within the GridView.CustomDrawFooterCell and GridView.CustomDrawGroupRowFooterCell event handlers. Here, you can obtain a total summary value using the GridSummaryItem.SummaryValue property, and GridView.GetGroupSummaryValue method. For convenience, we suggest that you set the GridGroupSummaryItem.Tag property of group summary items to user friendly values. So, you can use these values to easily obtain a necessary GridGroupSummaryItem from the GridView.GroupSummary collection.

Question Comments

Added By: Gunleif Bjartalid at: 4/7/2013 3:48:23 AM    

How can you change the format of calculated value to {0:c2}
now format is 1,40367865433345678789990 - how to make Kr 1,40

Added By: Uriah (DevExpress Support) at: 4/7/2013 11:54:22 PM    

Hello Ganleif,

I have created a new ticket on your behalf to discuss this issue: How to change the format of a summary value?. Please bear with us. We will answer your question as soon as possible.

Added By: Volker Niemeyer at: 6/21/2016 3:08:20 AM    This solution don't work for me.

I have create two Items (Gut and Schlecht) and one item to calculate (Anteil):
[VB.NET]
Dim item1 As GridGroupSummaryItem = New GridGroupSummaryItem() item1.FieldName = "Gut" item1.SummaryType = DevExpress.Data.SummaryItemType.Sum item1.DisplayFormat = "{0:#.##} kg" item1.ShowInGroupColumnFooter = .tblReport.Columns("Gut") .tblReport.GroupSummary.Add(item1)Dim item2 As GridGroupSummaryItem = New GridGroupSummaryItem() item2.FieldName = "Schlecht" item2.SummaryType = DevExpress.Data.SummaryItemType.Sum item2.DisplayFormat = "{0:#.##} kg" item2.ShowInGroupColumnFooter = .tblReport.Columns("Schlecht") .tblReport.GroupSummary.Add(item2)Dim item4 As GridGroupSummaryItem = New GridGroupSummaryItem() item4.FieldName = "Anteil" item4.SummaryType = DevExpress.Data.SummaryItemType.Average item4.DisplayFormat = "{0:0.##} %" item4.ShowInGroupColumnFooter = .tblReport.Columns("Anteil") .tblReport.GroupSummary.Add(item4)
Now I wan't to calculate them:

[VB.NET]
PrivateSub gridView1_CustomDrawRowFooterCell(ByVal sender AsObject, ByVal e As FooterCellCustomDrawEventArgs) Handles tblReport.CustomDrawRowFooterCellIf e.Column.Name = "colAnteil"ThenDim view As GridView = CType(sender, GridView)Try e.Info.DisplayText = Convert.ToDecimal(view.GetGroupSummaryValue(e.RowHandle, CType(view.GroupSummary("Schlecht"), GridGroupSummaryItem))) / Convert.ToDecimal(view.GetGroupSummaryValue(e.RowHandle, CType(view.GroupSummary("Gut"), GridGroupSummaryItem))) * 100Catch ex As Exception MsgBox(Err.Description)EndTryEndIfEndSub

I've got a NULL exception. Can you help?

Regards
Volker



Added By: Sasha (DevExpress Support) at: 6/21/2016 3:42:34 AM    

Hello,

I've created a separate ticket on your behalf (T394457: The NullReferenceException occurs in the "How to calculate summary based on the total summary of another column" example). It has been placed in our processing queue and will be answered shortly.

How to bind the Pivot Grid to Fields and Groups specified in ViewModel

$
0
0
This example shows how to put field and group definition logic in the ViewModel and setup the Pivot Grid Control.


How to color specific ButtonEdit's buttons by taking into account the current skin

$
0
0

This example demonstrates how to color a specific ButtonEdit's button using the SkinMaskColor property by taking into account the current skin. The main idea is to create a ButtonEdit descendant as described in the Custom Editors help article. Then, override the ButtonEditPainter.DrawButton method in order to draw the required button using your own LookAndFeel object.
Note that you can set the required button's color using the EditorButton.Appearance.BackColor property at design time or in code.

ASPxFormLayout - How to get an item using FindItemByPath method

$
0
0

This example shows how to access a single item by using LayoutGroupBase.FindItemByPath method.

Updated:

The ASPxFormLayout.FindItemByPath method and the LayoutItem.LayoutItemNestedControlContainer property are obsolete. It is recommended to use the ASPxFormLayout.FindItemOrGroupByName method and the LayoutItem.Controls property instead.

Question Comments

Added By: Marietha Jacobsz 2 at: 10/24/2013 6:59:51 AM    

Hi

LayoutItem.LayoutItemNestedControlContainer is deprecated, can you please update the examples related to this property?
Thanks
Marietha

How to Conditionally Apply Styles (CellStyle)

$
0
0

This example demonstrates how to apply a custom style to cells displayed within the 'Product Name' column based on a custom condition. A product's name is highlighted if the number of units is less than 20.

OBSOLETE. Starting from version 14.1, DXGrid introduces the built-in conditional formatting feature.

Question Comments

Added By: Bharadwaz Avvari at: 5/7/2014 2:38:37 AM    

there is No color change in the this example. I think something is missing please check it once again. and Re post it

Added By: Elliot (DevExpress Support) at: 5/7/2014 3:26:29 AM    This issue will  be processed in the How to Conditionally Apply Styles (CellStyle) ticket.Added By: aymeric daverat at: 5/9/2014 2:08:49 AM    

Hi, I have some troubles using this exmaple.
The cells are correctly colorized, but when I select the row, the default focused row color is not applied ( I would like the selected theme one)
What can I do then ?
Thanks a lot for your answer

Added By: Alexander Rus (DevExpress Support) at: 5/9/2014 4:00:14 AM    

Hi,
By default, when the xxxThemKey markup extension is used, resources are searched in the DeepBlue theme. When another theme is applied, it is necessary to use the ThemeName attribute in resource keys, for example:


BasedOn="{StaticResource {dxgt:GridRowThemeKey ResourceKey=CellStyle, ThemeName=MetropolisDark}}"

Thanks,
Alexander

Added By: Andrew Cope 2 at: 6/6/2017 5:39:46 AM    Very humorous.

T167030 direct s the developer to come here because conditional formatting is not adequate for their needs (I have the same problem). This solution is marked as obsolete and the developer is told to use conditional formatting.

Not very helpful.

How to use a TemplateColumn for showing and editing data

$
0
0

This example illustrates how to create a TemplateColumn for working with time values.

How to convert and then print an ASPxGridView by using the XtraReport

$
0
0

This example demonstrates how to dynamically create a report based upon the ASPxGridView control at runtime. This means that all filtering, sorting and grouping conditions selected in the grid are also applied in a report. To accomplish this task, it is necessary to create a report with all the necessary bands, bind it to a data source and adjust all the necessary options.You can use this approach if you need to display content of templated columns in your report or insert a report based on ASPxGridView to another report.

See also:
E4755: How to convert and then print an GridView extension by using the XtraReport

Question Comments

Added By: Opus 5K at: 9/12/2013 12:01:12 AM    

Dear support. I have been trying for several days now to export custom cell templates of a pivotgrid but with no luck. From my previous posts, I understand that the exporting of pivotgrid custom cells is not supported, nor are there any plans to support this in the future. This is a serious shortfall for us and could mean that we are just not able to use your controls if we are not able get the data out to the users.

I then came across this post which appears to be doing exactly what we need to do, although this is doing it against a ASPXGridView and not against a ASPXPivotGrid.

I have been trying to "translate" the C# code so that it instead works off of the ASPXPivotGrid but have not been able to.

Is there any chance that somebody there could provide the equivalent sample that will take a ASPXPivotGrid and create a report out of it which includes the templated cells? As an ideal example, if you are able to show how this code would work against your own templated example found here: http://demos.devexpress.com/aspxpivotgriddemos/Templates/CellTemplates.aspx

I have seen several posts now where users are requesting the ability to export templated cells from the pivotgrid, so I am sure any assistance/sample code you can provide along the same lines as what you have done here will be very useful for quite a few of us.

Thanks in advance

Added By: Andrew L (DevExpress Support) at: 9/12/2013 3:08:43 AM    

Hello,

To export an ASPxPivotGrid control with custom templates use an approach from : http://www.devexpress.com/Support/Center/CodeCentral/ViewExample.aspx?exampleId=E2686 example.

Added By: Cristiano2s at: 2/4/2014 11:18:30 AM    

Hi,

this example works fine and it was very good to my application. But i need the same to excel, and when i did the changes i lost the header. Do you have the same example or just the part to export to excel?

Added By: Vijay Macha at: 5/29/2014 2:51:45 PM    

Hi,
This example is great. Can we export GridviewBand column also in this approach.  we are using devexpress 2014 v1.2

Added By: Nick Hoare at: 7/22/2014 9:27:20 AM    

In ReportHelper.vb, in InitDetailsandPageheader cell.Text is set to the FieldName where I think it should really be set to the ColumnCaption to make use of the work done in GetColumnsInfo which selects the ColumnCaption to be the Caption if there is one or FieldName if there isn't.  It certainly works better for me.  This affects C#,  VB and the MVC example code.
                  
cell.Width = columns(i).ColumnWidth
cell.Text = columns(i).ColumnCaption  'Better to show the Caption than the examples columns(i).FieldName
row.Cells.Add(cell

Added By: jag zao at: 3/6/2015 12:12:24 PM    

I was able to replicate this example, to my needs, but unfortunately there is a problem with the tables label headers, because it does not use the one in the grid caption
How can I change this, since its using the class name, not the grid caption

Added By: Mike (DevExpress Support) at: 3/9/2015 12:54:22 AM    

Hello Jag Zao,

To process your recent post more efficiently, I created a separate ticket on your behalf: T216993: How to convert and then print an ASPxGridView by using the XtraReport + Keep Grid Caption. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: urmila shelke at: 4/19/2017 2:15:22 PM    Can I get the running sample of this code, Please?
Added By: Lex (DevExpress Support) at: 4/20/2017 1:29:20 AM    Hello Urmila,

You can download the sample and run it on your side using our Example Runner. You can download both by clicking on the following links:

If this doesn't suit your requirements, please submit a separate ticket and we will do our best to find a precise solution for you.Added By: urmila shelke at: 4/20/2017 7:38:55 AM    Thank you!
Added By: Ronald Kunce at: 6/6/2017 12:47:00 PM    This example is exactly what I need to convert and print a filtered/sorted VB ASPxGridview using XtraReports.  However, it is dependent upon passing a SQL data source to the report generator code for which I cannot see how to do this as the gridview's data souce is a dataset returned from a call to an SQL stored procedure.  I tried replacing the SQL Data Source with a Dataset, but it will not accept  it as the InitDataSource method demands an SQL Data Source.  Is there something I am missing that will turn the gridview resultant display to an SQL Data Source (with filters and sorting)?   

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

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();});}

 
See also:
T466761: Web Dashboard - How to implement the Save As and Delete functionality by creating custom extensions


dxTreeList - How to implement recursive selection

$
0
0
This example illustrates how implement recursive node selection.

How to customize command buttons in individual rows

$
0
0

This example demonstrates how to hide a command button in the grid's CommandColumn by handling the ASPxGridView.CommandButtonInitialize event.

See Also:
How to hide a cell value
How to hide template controls in individual cells
How to conditionally disable the UpdateButton in client code
How to create a custom command button with the appearance and action depending on a row state
How to enable/disable command buttons on the client side

Question Comments

Added By: Jacob Blumberg at: 8/28/2013 3:30:46 PM    

Is there a way to do this based on the data in the row?

Added By: Balaji BLS at: 6/9/2017 2:26:46 AM    Hello Support,

How to implement same functionality in MVC?

How to modify the color of the form's caption at runtime

$
0
0

This example demonstrates how you can utilize the Skin Engine to change the color of any form's element. In this example, you can find some code, illustrating how any skin element can be modified at runtime.

Question Comments

Added By: Stanislav Kucherenko at: 6/9/2017 4:04:46 AM    Hello,
Could you please advice, how to change this example so as it would be possible to distinct active/non active windows.
I mean, the first one color value for background color for title of active windows and the second one for non active windows.

Thanks!

How to show underlying data in a custom grid dashboard item

$
0
0
This example illustrates how to create a custom grid dashboard item to show underlying data that it is possible to get using the RequestUnderlyingData method.

How to implement the Drag&Drop functionality for the CardView

$
0
0

We have created an example demonstrating how to implement the Drag&Drop functionality for the CardView.

This functionality is encapsulated in the CardDragDropManager class. So, all you need to do is to attach this behavior to the GridControl.

Question Comments

Added By: A Dev at: 10/24/2014 12:19:57 PM    

Where to find the DragDropManagerBase class?

Added By: Ivan (DevExpress Support) at: 10/24/2014 12:47:27 PM    

You can find this class in the C:\Program Files (x86)\<DevExpress folder>\Components\Sources\DevExpress.Xpf.Grid\DevExpress.Xpf.Grid.Extensions\DragDrop\DragDropManager\DragDropManagerBase.cs file. Note that this file will be installed regardless your subscription type. It's available for trial users as well.

Added By: Jobert Galamiton at: 9/21/2016 11:34:35 PM    Hi,

This doesn't work with the latest version. Please advise. Added By: Andrey Marten (DevExpress Support) at: 9/22/2016 1:37:14 AM    

Hello,

I've created a separate ticket on your behalf (T430564: The approach from E4616 does not work in v16.1.6). It has been placed in our processing queue and will be answered shortly.

Thanks,
Andrey

Viewing all 7205 articles
Browse latest View live


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