Unlike WinForms, where an embedded font can be registered globally using the PrivateFontCollection, WPF requires explicit reference to the embedded font. This sample application demonstrates how to work around this limitation.
See also:
E5198: How to use a private font (a custom font distributed with the application) in XtraReport
How to display a report that uses a private font (distributed with the application) in DocumentPreview
How to use a private font (a custom font distributed with the application) in XtraReport
This example demonstrates how to use a custom font distributed with the application in XtraReport.
The main idea of this approach is to use the PrivateFontCollection class to store custom font families. Use the Families property to access the FontFamily objects of your private fonts.
In this example, the static "FontCollection" property is used to store the report's private fonts. Then, in the report constructor, the private font families are used to specify fonts of the report controls.
This is a cross-platform approach, so it can be used for all technologies supported by XtraReports. However, there are some notes:
ASP.NET
The private font will be available only on your web server, so it won't be displayed in ASPxDocumentViewer by default if it is not installed on the client machine.
However, you can register this custom font on your webpage, for example by using the @font-face CSS rule. In this case, add this rule to your webpage with the viewer and set your ASPxDocumentViewer.SettingsReportViewer.UseIFrame property to the "false" value to prevent your report from being rendered in an iframe. This approach is demonstrated in this example.
WPF
The font cannot be registered globally by using the PrivateFontCollection in WPF, so the explicit reference to the embedded font is required there. The E5083: How to display a report that uses a private font (distributed with the application) in DocumentPreview code example demonstrates how to work around this limitation.
How to implement a client-side confirmation on the user action modifying the appointment
This example demonstrates how drag-n-dropping and resizing appointment actions can be confirmed using client-side scripting technique. The ASPxScheduler client-side events AppointmentDrop and AppointmentResize are handled to show a dialog window prompting the end-user to apply changes. If "OK" button is clicked, the Apply method of the ASPxClientAppointmentOperation object that is passed to the displayed popup control, is executed. Otherwise, it calls the Cancel method. The Apply method raises the callback and accomplishes the appointment modification. The Cancel method leaves the appointment intact.
Note the use of the temporary property cpOperation to hold the ASPxClientAppointmentOperation object obtained in the event handler.
Question Comments
Added By: DClayton at: 7/21/2014 9:40:05 AM
I've been pointed to this as a solution to my problem, I am setting my function on the code behind
btnOk.ClientSideEvents.Click = "function(s, e) { OnBtnOKClick(); }";
then in my javascript I am trying to save the appointment, but e is undefined.
what am I doing wrong?
function OnBtnOKClick(s, e) {
scheduler.cpOperation = e.operation;
scheduler.cpOperation.apply();
};
To process your recent post more efficiently, I created a separate ticket on your behalf: <sclink viewType="IDSubject" id=T132019" />.
This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.
How to use a third-party jQuery plug-in (accordion) in a DevExtreme application
This example demonstrating an approach described in the How to create widgets using a "jQuery approach" in a mobile application Knowledge Base article.
Question Comments
Added By: Emanuele Politi at: 7/21/2014 4:41:42 AM
it's possible apply that approach on viewShowing action and not on viewShown ?
the loading of accordion on viewShown is visible.
Hello,
To process your recent post more efficiently, I created a separate ticket on your behalf: How to avoid visual artifacts when adding the accordion widget to a dxView?. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.
How to create a ButtonEdit descendant showing EditValue in button's caption
This example illustrates how to create a ButtonEdit descendant that creates the second default button and shows EditValue in its caption. When you type text in the editor it is shown in a caption of the second button.
ASPxDocumentViewer - How to dynamically preview a report in document viewer after a button was clicked
This example demonstrates how to load a report to ASPxDocumentViewer control dynamically at runtime.
The ASPxDocumentViewer control uses a callback to display a report. According to the ASP.NET Page Life Cycle, the ASP.NET WebForms page state should be restored on all postbacks and callbacks. To make the ASPxDocumentViewer control work correctly, a report that was dynamically assigned to it should be restored when the page is reloaded on a callback.
Take special note that if the report is not restored on a callback, the ASPxDocumentViewer control remains empty after assigning a report to it.
In this code example, the Session variable is used to save the ASPxDocumentViewer state. When the page is loaded for the first time, the Session variable is not yet specified and the ASPxDocumentViewer remains empty. But after the button is clicked, the currently displayed report name is saved into the session (in the btPreview_Click event handler). Then, when the page is reloaded, this name is used to restore the report (in the Page_Load event handler).
How to convert and then print an ASPxGridView by using the XtraReport
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 AMHello,
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 AMHi,
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 PMHi,
This example is great. Can we export GridviewBand column also in this approach. we are using devexpress 2014 v1.2
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
How to implement the master detail GridView with editing capabilities
This example illustrates how to implement the master detail GridView with editing capabilities.
Perform the following steps to define the master-detail layout:
1) Define both master and detail GridView settings within separate PartialView files (see the Using Callbacks);
2) Set the master grid's SettingsDetail.ShowDetailRow property to "True";
3) Define the master grid's DetailRow content via the SetDetailRowTemplateContent method and render the detail grid's PartialView inside.
Note:
Values passed in a detail grid's CallbackRoute must have a unique name and must not replicate any other names on a page: Q577974: GridView - "The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32'" error occurs when canceling editing in the detail GridView
Question Comments
Added By: Wilson Vargas at: 10/20/2012 12:08:04 PM
This sample not compile!
settings.DataBinding = (sender, e) => {
((MVCxGridView)sender).ForceDataRowType(typeof(DevExpress.Razor.Models.Person));
Excellent - just what I needed!
How to convert and then print an GridView extension by using the XtraReport
This example demonstrates how to dynamically create a report based upon the GridView extension 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 GridView to another report.
As it is impossible to get the GridView extension state (its filtering, groping, sorting info), the Session is used to pass the last GridView state to the controller.
See also:
E4476: How to convert and then print an ASPxGridView by using the XtraReport
Question Comments
Added By: Kiran Pratapagiri at: 7/3/2013 12:46:27 AM
Hi,
Thanks for the example.
I think I found the problem with this example. It's not exporting the last column of the Grid.
Please correct the example to export the last column into report.
Thanks
Added By: Diogo Azevedo 1 at: 10/24/2013 8:23:13 AMthis example works for version 2012?
Added By: Vasily (DevExpress Support) at: 10/24/2013 11:31:20 PMYes, this example should work with version 2012. Anyway, if you face any issues after converting this example to version 2012, please feel free to create a separate support ticket for this issue.
Added By: Nick Hoare at: 7/22/2014 9:28:47 AMIn 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 ASPxGridView 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
Thank you for your feedback. This example demonstrates how to generate an XtraReport from ASPxGridView, so we will not change its code now.
Anyway, feel free to modify the code provided in this example according to your scenario.
How to load data in an unbound column asynchronously
This example illustrates how to load data in an unbound column asynchronously.
Question Comments
Added By: Maxime MERIAUX at: 7/23/2014 3:00:33 AM
Hello,
this sample is great, but it doesn't work if the grid displays details information of a master binding source as the e.ListSourceRowIndex can be the same when master row changes...
considering I have a Fk bindingsource for that grid, I tried to access the master BindingSource and get the current index... but I have threads problems as the bindingsource is used by another thread.
Can you advise on this?
Best regards.
Added By: Maxime MERIAUX at: 7/23/2014 6:12:06 AMWell I used the Datarow index instead, works well...
I do not know if this is a consequence, but I have now the following error:
BindingSource cannot be its own data source. Do not set the DataSource and DataMember properties to values that refer back to BindingSource.
at System.Windows.Forms.BindingSource.get_Count()
at DevExpress.Data.Helpers.BaseDataControllerHelper.get_Count()
at DevExpress.Data.DataControllerBase.get_ListSourceRowCount()
at DevExpress.Data.DataController.get_VisibleListSourceRowCount()
at DevExpress.Data.DataController.IsControllerRowValid(Int32 controllerRow)
at DevExpress.Data.CurrencyDataController.IsControllerRowValid(Int32 controllerRow)
at DevExpress.Data.DataController.GetRowValue(Int32 controllerRow, Int32 column, OperationCompleted completed)
at DevExpress.Data.BaseListSourceDataController.GetRowValue(Int32 controllerRow, Int32 column, OperationCompleted completed)
at DevExpress.XtraGrid.Views.Grid.GridView.GetRowCellValue(Int32 rowHandle, GridColumn column, OperationCompleted completed)
at DevExpress.XtraGrid.Views.Grid.GridView.GetRowCellValue(Int32 rowHandle, GridColumn column)
at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcRowCellDrawInfo(GridDataRowInfo ri, GridColumnInfoArgs ci, GridCellInfo cell, GridColumnInfoArgs nextColumn, Boolean calcEditInfo)
at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcRowCellsDrawInfo(GridDataRowInfo ri, GridColumnsInfo columnsInfo)
at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcDataRow(GridDataRowInfo ri, GridRow row, GridRow nextRow)
at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcRowsDrawInfo()
at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcGridInfo()
at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.Calc(Graphics g, Rectangle bounds)
at DevExpress.XtraGrid.Views.Base.ColumnView.DoInternalLayout()
at DevExpress.XtraGrid.Views.Base.ColumnView.CalculateLayout()
at DevExpress.XtraGrid.Views.Grid.GridView.LayoutChanged()
at DevExpress.XtraGrid.Views.Base.BaseView.EndUpdateCore(Boolean synchronized)
at DevExpress.XtraGrid.GridControl.EndUpdate(Boolean synchronized)
How to obtain filtered data from GridControl in the MVVM style
This example shows how to return the collection of visible rows to the ViewModel. For more details, refer to the KA18591: How to synchronize filtered data between the GridControl and ViewModel KnowledgeBaseArticle.
Question Comments
Added By: Kerry Patrick at: 7/23/2014 8:31:53 AM
Hello.
Thank you so much for this example. One problem I encounter when using this code is when I have a GridColumn which uses a custom binding because it relies on an IValueConverter. For example:
<dxg:GridColumn UnboundType="String" Binding="{Binding ItemizedInstruments, Converter={StaticResource ListHasItemsToYesNoConverter}}" Header="Itemized?" ReadOnly="True" Width="Auto" >
</dxg:GridColumn>
After poking around a little bit in the visible object model, it appears that the list of visible row handles can be obtained in the OnFilterChanged event by querying grid.DataController.FilterHelper.VisibleListSourceRows.ToArray(). You can then loop through the handles and call visibleData.Add(grid.GetRow(handle)) to get the collection of visible objects. Can you tell me if this is also an acceptable way to keep the visible objects in sync between the view model and the GridControl, or are there pitfalls to this approach?
Kindest regards,
Kerry
How to generate multi-resource appointments at runtime
ASPxGridView - How to show a confirmation dialog using ASPxPopupControl
This example demonstrates how to show a delete confirmation dialog using ASPxPopupControl. In this example, ASPxGridView is created with a custom button; the ASPxClientGridView.CustomButtonClick event is handled. ASPxPopupControl is shown on ASPxClientGridView.CustomButtonClick and if the ASPxPopupControl's "Yes" button is clicked, then the ASPxClientGridView.DeleteRow method is called.
See also: How to implement a delete confirm dialog with a "don't ask me again" option
GridView - How to show a confirmation dialog using PopupControl
Question Comments
Added By: Bala Chinni at: 7/24/2014 5:08:14 AM
Hi,
I am new to DevExpress.
When I am implementing this code as it is with my database, row deletion is happening from second click onwards, I mean for the first click no deletion of the row is happening.Please help me
Hello,
To process your recent post more efficiently, I created a separate ticket on your behalf: T133290: ASPxGridView - When row deleting confirmation dialog is enabled, the deleting occurs on a repetitive mouse click after closing the confirmation dialog. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.
XtraGrid - How to draw a GridControl background image
This example demonstrates how to draw an image behind the GridControl rows
How To: Implement Sorting for a Custom Cell Value
In the current version, PivotGridControl doesn't support sorting by summary values, replaced in the PivotGridControl.CustomCellValue event. It's because PivotGridControl first filters, groups and sorts cell values and then raises the PivotGridControl.CustomCellValue and PivotGridControl.CustomCellDisplayText events. This example demonstrates how to implement sorting for such values. Note that this solution will work in simple cases and depends on the layout. In many cases, when it's not required to get other cell values, this approach can be replaced with handling the PivotGridControl.CustomSummary event.
Some key points include:
- In the PivotGridControl.CustomFieldSort event, custom cell values can't be obtained because they are not formed by this moment. The FormLoad event is used to remember custom field values into a special variable for further calculation in the PivotGridControl.CustomFieldSort event.
- As PivotGridControl sorts cell values by SortBySummaryInfo, to disable sorting by summary, PivotGridControl.ShowMenu event is handled to prevent fields sort menu from being shown. The PivotGridControl.MouseClick event is handled to calculate sort info when a user clicks PivotGridControl's column value.
-When you sort pivot rows or columns by summary values, the PivotGrid uses the sort order specified in row or column fields, and does not use sort settings from a data field used for sorting. PivotGridControl.CustomFieldSort event is handled for the PivotArea.RowArea field. This allows users to change the row values order by comparing remembered custom cell values in the cell area using sort info calculated on the PivotGridControl.MouseClick event.
Question Comments
Added By: D. Samsonoff at: 10/25/2013 7:56:49 AM
Quite fragile code. Several issues before this can be used by anyone:
- Difficult to make it work generically. We have a mix of Unbound (some of which rely on CustomCellValue for sourcing data) and Bound fields.
- Sorting needs to work of Menus just as for the supported fields as we have a mixture (see above). More hacking required.
- Consider changes to Row Fields. So additional event handling is required to reset caches.
- Memory footprint and performance is degraded.
Please fix your code so that values produced by CustomCellValue event are fully integrated into infrastructure and can be used with Filtering and Sorting out-of-the-box.
Added By: Martin D. at: 7/24/2014 4:23:45 PMHi,
this sample is broken. It's on .net 3.5 - so doesn't work with 14.1 dx
Upgrading it to .net 4.5 - causes issues with Table adapted.
could You plz fix it ?
ASPxGridView - How to implement copy functionality in Batch Edit mode
This example demonstrates how to add copied values to a new row on a custom command button click using a new client-side API implemented in the following threads:
ASPxGridView - Batch Edit mode - Provide a client-side API to obtain/modify cell values without entering edit mode
ASPxGridView - Batch Edit mode - Provide client-side events that allow responding to entering and leaving the edit mode
MVC Version:
T115891: GridView - How to implement copy functionality in Batch Edit mode
GridView - How to implement copy functionality in Batch Edit mode
ASPxGridView - Batch Edit mode - Provide a client-side API to obtain/modify cell values without entering edit mode
ASPxGridView - Batch Edit mode - Provide client-side events that allow responding to entering and leaving the edit mode
WebForms version:
T114985: ASPxGridView - How to implement copy functionality in Batch Edit mode
WinForms End-User Designer - How to customize the data source wizard connection string storage
By default, the report connections list is populated based on the connections stored in the application configuration file. In any case,, the application configuration cannot be modified at runtime, that's why the report connections list is not changed when the Reports End-User Designer is used.
To initialize, save and restore the connection strings in the Reports End-User Designer, use the approach demonstrated in this code example.
The main idea of this approach is to create a custom connection storage service (the ConnectionStorageService class descendant). Also, the SqlDataConnection class descendant (CustomSqlDataConnection) is used in this example to customize the connection names in the connections list.
Question Comments
Added By: Wolf Hermann at: 7/24/2014 11:53:44 PM
Hello! Sorry, I cant find some custom connections running this demo?
Thanks for your help, kind regards
Wolf
Hello Wolf,
To process your recent post more efficiently, I created a separate ticket on your behalf: T133798: WinForms End-User Designer - How to customize the data source wizard connection string storage code example - Cannot find connections. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.
How to implement the Master-Details functionality with the ServerMode enabled (the LinqServerModeSource is used as the grid's DataSource)
In the 2012 vol 1 version we implemented a Master-Detail feature, and now we provide it out of the box.
Linq queries are created for the Product and ProductModel tables from the AdventureWorks DB. This DB can be downloaded by the following link: AdventureWorks DB
1. Create a linq query for ProductModel table;
2. Assign this property to the LinqServerModeSource.QueryableSource property; 3. Create a filtered linq query for the nested grid Product table.
The solution is to implement a multi-binding converter. In this converter, pass
the RowHandle and ActiveView. In the Convert method, create a new query. In the query, filter the Product based on the ProductModelID property
value of the current row. Also, create a new LinqServerModeSource object for the detail view, and assign your new query to the
LinqServerModeSource.QueryableSource property.
Use only one scroll bar for a grid with multiple master/detail levels.
A grid containing a number of groups (master), each with a number of lines (detail) is a representation of an order which is grouped for readability. When a group has a greater number of lines then fits on the screen, a scrollbar is added to the detail-view and when there are multiple groups the master-view also gets a scrollbar. When the user scrolls through the grid, only the master-view is scrolled (unless a row is selected, then only the detail-view is scrolled) and it feels like the program is behaving oddly, as half the rows are skipped.
To achieve this goal, we need the GridControl to have a height equal to the height of all content placed in a master-view. So, the scrollbar does not appear in either the master-view or in the detail-view. To allow scrolling, we need to put our GridControl into a XtraScrollableControl and set the GridControl.Dock property to DockStyle.Top.
We created the MyGridControl class - a descendant of the GridControl. MyGridControl works with MyGridView views and includes the CalcGridHeight() method, which is called when the appearance of the Master-View is changed.
To put MyGridControl in the XtraScrollableContainer, use the MyGridControl.InitScrolling method at runtime. Use the MyGridControl.InitScrollingInLayout method to initialize scrolling in a LayoutControlItem.
Please note that if you want to change Bounds or Dock properties of MyGridControl at runtime, change similar properties of the MyGridControl.ScrollableContainer control.
Question Comments
Added By: Pascal Veilleux (Seika) at: 11/26/2012 7:29:29 PM
The solution works great except that with that solution, since the XtraScrollableContainer contains the whole grid, we loose the header when we scroll so the user must scroll to the top to be able to sort, group, ...
Added By: Stécy at: 5/9/2014 6:14:11 AMDoes not work if the grid is inside a layout control. How to fix?
Added By: Ekaterina (DevExpress Support) at: 5/11/2014 11:24:18 PM Hi,I've created the The 'Use only one scroll bar for a grid with multiple master/detail levels.' example doesn't work when a grid is inside a LayoutControl ticket. Let's discuss the issue related to LayoutControl there.
Added By: Steven Haworth (Visy) at: 7/28/2014 4:16:25 PMI have found that this control will crash with an "Overflow Error" Exception when using the Zoom functionality on 14.1.5.
Setting Master_GridView.OptionsDetail.AllowZoomDetail to false will make it crash when you click on the zoom button - even though it does not have the zoom glyph.
Setting Master_GridView.OptionsDetail.AllowZoomDetail to true, zooming the detail works, but restoring it back will crash it.
You can fix this by clearing the code in the MyGridView.ZoomView override but I don't know how to fix if you do want zoom functionality.
Added By: Alisher (DevExpress Support) at: 7/29/2014 12:09:42 AMHello,
To process your recent post more efficiently, I created a separate ticket on your behalf: T134620: Overflow Error exception occurs when using Zoom functionality in the E4376 example. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.