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

How to custom draw in PDF Viewer

$
0
0
The PDF Viewer can draw graphics in the PDF document in the Control.Paint event handler.

In this example, the filled rectangle is drawn at any document space when you hold down the left mouse button and move it. 

The PDF Viewer gets the mouse position relative to the PDF Viewer by calling the PdfViewer.GetDocumentPosition method in the MouseDown (when the left mouse is pressed), and  MouseMove event handlers (when the mouse is moving).

To draw a filled rectangle in the PDF document, the RectangleF.FromLTRB method is called in the Paint event handler. The start and end client points are obtained using the document position in the PdfViewer.GetClientPoint method. 

This example also shows how to draw a rectangle using the Graphics.FillRectangle method.

How to implement a data service that supports remote operations for dxDataGrid

$
0
0
This example demonstrates how to implement a data service based on ASP.NET WebAPI that supports remote operations for the dxDataGrid widget. The main idea is to get all parameters passed from the client side and use them when loading data from a data base to prepare data in the required manner. Please refer to the Use Custom Store - Remote Operations help topic to learn more about all supported remote operations of dxDataGrid. You can see implementation of a custom store for dxDataGrid in the dxDataGrid - How to implement a custom store with CRUD operations example.

See also:
How to implement the Rest service based on an ASP.NET WebAPI application

dxDataGrid - How to implement a custom store with CRUD operations

$
0
0

The dxDataGrid binding using a CustomStore help topic and the A custom data source does not apply paging, filtering, sorting and grouping article describe how to implement a custom data source that loads data for a dxDataGrid . This example demonstrates how to make a custom store for the dxDataGrid widget manipulate data. For this purpose, we need to implement the insertupdate and remove methods in our custom store. Each of these methods will be called automatically by the widget. 

The insert method accepts a parameter that contains values for a new item. The update method accepts two parameters: the first one is a key value of the editing row, and the second one contains values of modified data fields. The remove method accepts a parameter that contains a key value of the deleted row. When a method is called, we need to send a corresponding request to our data service and pass the required parameters. We use jQuery.ajax for sending requests to our data service.

Starting with 15.2, dxDataGrid supports sorting, filtering, grouping, paging and summary operations on the server side. See Use CustomStore - Remote Operations to learn more. The How to implement a data service that supports remote operations for dxDataGrid example demonstrates how to do this.



For versions prior to 15.2: 
This example can be tested with a data service from How to implement the Rest service based on an ASP.NET WebAPI application.


See also:
Use CustomStore - Remote Operations
Deferred Object
jQuery.extend
How to implement CRUD operations with a DataSource
dxDataGrid - How to implement a custom store with CRUD operations (SQLite)
Question Comments

Added By: Matthias Klein at: 10/6/2015 11:05:23 AM    

Is this a typo in line 20? ("lebgth")

Added By: Matthias Klein at: 10/6/2015 12:05:10 PM    

I have a date field in my dxDataGrid. When I update or insert a row the date is in the Format: "Thu Oct 08 2015 20:55:06 GMT +0200)". How can I change the format in which the date fields will be transfered as data?

Added By: Nikolai (DevExpress Support) at: 10/7/2015 2:23:35 AM    Hi Matthias,

Thank you for bringing this to our attention. I've updated our code.

As for "date field in my dxDataGrid", I've created a new ticket regarding this issue. Please post your comments in the T297669: dxDataGrid passes the string interpretation of a Date value to insert/update methods of CustomStore ticket.

 

How to implement a Control Template Gallery in the End-User Designer to provide the capability to create reusable control sets

$
0
0
This example demonstrates how to add the capability to save selected controls and reuse them in this or other reports like UserControls in standard Windows Forms application.

Implementation Details:
In the scope of this example, we add a custom End-User Designer DockPanel and fill it from the predefined storage (if this storage is not empty), which can be passed to the constructor or Storage property of a custom ReportDesignTool descendant. The storage should implement the IControlTemplateStorage interface, which declares the following members:

- GetCategoryNames. This method should return string representations of all template categories in your storage.
- GetTemplateNamesForCategory. This method returns template names for the specified category.
- GetData. This method returns a byte array containing stored controls.
- SetData. This method allows you to save a byte array representing saved controls.
- DeleteTemplate. Use this method to delete the specified template from your storage.
- DeleteCategory. Use this method to delete the specified category and inner templates.

In this Code example, you can find two sample implementations of this interface. The first one (ControlTemplateStorage) demonstrates how to create an in-memory storage, and the second one uses a DataSet instance for storing templates.

UI for Template Gallery:
As stated above, we added a custom Dock Panel that has two buttons (Add and Delete) for operating with templates and a TreeList instance that displays existing categories and templates. To create a new template, select the required controls in your report and click the Add button. You will see a new dialog requesting the Category and Template name.

To create controls from a template, select the required template in the TreeList and drag-and-drop it to a report design surface at the required location.

To delete a template or category, select it in the TreeList and click the Delete button.

How to access the values stored in HttpContext/Session while working with the ASP.NET HTML5 Document Viewer and End-User Report Designer controls

$
0
0

This example demonstrates the approaches described in the T339643: How to access the values stored in HttpContext/Session while working with the ASP.NET HTML5 Document Viewer and End-User Report Designer controls article.

A report instance is created in the custom report storage extension (SampleReportStorageWebExtension class) GetData method's code. The values stored in the HttpContext/Session (the session field and the User name) are used there to initialize the report parameters. The report displays these parameters values in the ReportHeaderBand. Also, these parameter values are passed to the ObjectDataSource's data class's (ReportDataItem class) GetReportData method that is used to populate the report with data.

How to integrate a charting module - example solution

$
0
0

This solution includes ready-to-use project templates for the Implementing a charting module with the XtraCharts SuiteKB article.

Question Comments

Added By: RFuente at: 2/3/2016 1:58:55 AM    Please update the examples.
Visual Studio does no longer include Sql Server Compact and there is no easy way to run this projects. The fail loading Northwind.sdf databases.

Generated Data Access Layer with Entity Framework Database First

Generated Data Access Layer with Entity Framework Code First


Generated Data Access Layer Based On Data Provided By a WCF Service

ASPxCardView - How to update total summaries on the client side in Batch Edit mode

$
0
0
This example demonstrates how to update total summaries on the client side when ASPxCardView is in Batch Edit mode.

Scaffolded Application based on Data Access Layer generated with Entity Framework Database First

$
0
0
This example is built with the Scaffolding Wizard based on Data Access Layer generated with Entity Framework Database First. The example is the result of the following tutorial: UI Generation

Scaffolded Application based on Data Access Layer generated with Entity Framework Code First

$
0
0
This example is built with the Scaffolding Wizard based on Data Access Layer generated with Entity Framework Code First. The example is the result of the following tutorial: UI Generation

How to dynamically add and remove controls within ASPxCallbackPanel on callbacks

$
0
0

This example demonstrates how you can dynamically add and remove controls within an ASPxCallbackPanel on callbacks. In this case, a ViewState is not applied so it should be disabled (the EnableViewState property is set to false). A hierarchy of controls, which have been created on callbacks, should be recreated on Page.Init event.


In this example, tabs with custom content can be dynamically added to an ASPxPageControl on callbacks. In order to recreate a hierarchy of dynamically created controls (within tab pages) the tab information is saved to a Session object.


Additionally, the example demonstrates the usage of ASPxPageControl.TabTemplate property to specify a tab text and a close button.

Question Comments

Added By: Mark Germishuys at: 2/3/2016 1:37:06 AM    still removes previously created tabsAdded By: Artem (DevExpress Support) at: 2/3/2016 3:55:33 AM    

Hello Mark,

To process your post more efficiently, I created a separate ticket on your behalf: T341626: E4113 works incorrectly. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Lesson 5 - Bind a Scheduler to MS SQL Database at Design Time

dxDataGrid - How to implement a custom store with CRUD operations (SQLite)

$
0
0

This example can be tested on a mobile device and it cannot be tested in the DevExtreme simulator.

The dxDataGrid binding using a CustomStore help topic and the A custom data source does not apply paging, filtering, sorting and grouping article describe how to implement a custom data source that loads data for a dxDataGrid . 

This example demonstrates how to make a custom store that works with a SQLite data source. For this purpose, the SQLite PhoneGap plugin is used. Note how the custom store's insertupdate and remove methods are implemented to use the plugin's API. Each of these methods will be called automatically by the widget.  When a method is called, we need to execute a corresponding SQL query and pass the required parameters. Note that in order to work with the database, it is necessary to initialize it in the "deviceready" event handler:

[JScript]
//index.js $(document).on("deviceready", function(){... window.db = window.sqlitePlugin.openDatabase({ name: "DB"});});

Note how the deferred object resolves the amount of affected rows in each method and the reject function receives the exception message. This allows displaying the query execution exception in the grid's error row.

The example contains a ready-to-use package file for Android, so you can install and test it right away. Any modification or building the package for iOS will require going through steps described in Packaging.

See also:
Deferred Object
How to implement CRUD operations with a DataSource
dxDataGrid - How to implement a custom store with CRUD operations

Question Comments

Added By: Vivek Kanakia at: 7/3/2015 7:21:12 AM    

Hi,

I want to create mobile and web app using devExtreme
I want to give user offline capability.
Does devExtreme support CRUD operations out-of-the-box for offline storage.

Do you have sample code which demonstrates how to make a custom store like SQLite data source. Or any other data source.

I am interested in knowing insert, update and remove methods implemention. Each of these methods needs to be called automatically by the widget.  

Thanks & Regards,
Deepak Chavan, PMP

Added By: Anthony (DevExpress Support) at: 7/3/2015 12:36:38 PM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T263266: Inquires regarding the offline storage . This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Rodi Pivetta at: 12/30/2015 2:32:24 AM    

I try this application on android mobile phone and work fine.
But if I try to run this application with mobile device simulator (using built in Sqlite)  I get the error

Error: 'Uncaught TypeError: Illegal invocation', line 25, file 'http://localhost:62976/js/db.js';.

in the row with code:
for (var prop in items(i)) {

How can I solve this? Is possible debuq Sqlite application with mobile device simulator?

Added By: Anthony (DevExpress Support) at: 12/30/2015 3:48:58 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T329548: The 'Uncaught TypeError: Illegal invocation' error occurs when using the T218257 example in mobile device simulator. This ticket is currently in our processing queue. Our team will address it soon.

Added By: Mustafa Ezdemir (Berka Hizmet) at: 2/4/2016 4:16:50 AM    for succes insert request;

//db.js;
.....
    insert: function (values, deferred) {        var columns = [],            vArray = [],            v = []        for (var prop in values) {           if (prop != "__KEY__") {                columns.push(prop);                vArray.push(values[prop]);                v.push("?");            }        }
......

Report Storage for the End-User Report Designer (WPF beta)

$
0
0
The following example demonstrates how to implement a report storage to persist report definitions in a database or in any other custom location. This may be useful when providing end-users with the capability to create and customize reports using XtraReports End-User Designer if it is necessary to have a common target for saving and sharing all reports. At present, the aforementioned functionality is accomplished through the DevExpress.Xpf.Reports.UserDesigner.IReportFileStorage interface. The interface provides the following methods:
       • ShowSaveAsDialog
       • ShowOpenDialog
       • Load
       • Save
       • GetErrorMessage
As we see, the interface methods are quite straightforward: the first two methods are intended to show a dialog to an end-user where he can select a report among the predefined reports, or otherwise, save it; when he does that, the Save or Load methods are invoked with the unique name of the selected report. That's where you should implement your custom save logic. If you're unfamiliar with this procedure, please refer to the original E2704 example, which provides additional information in this regard (the example illustrates the same technique but for WinForms EUD)
__________________________________________________________________________________________________________________________________________

[v15.2 History changes]
The IReportFileStorage interface has been changed to IReportStorage.
This new interface provides the following methods:

• bool CanCreateNew();

Indicates where or not it's possible to create a new tab with a blank report in the designer.
• bool CanOpen();

Indicates where or not the "Open" BarItem is enabled.
• XtraReport CreateNew();

Provides the capability to customize a new report template.
 • XtraReport CreateNewSubreport();

Provides the capability to customize a new subreport report template (i.e., a new report opened by double-clicking a given XRSubreport control)
• string GetErrorMessage(Exception exception);

Provides the capability to display an error message for any encountered exception (a general one or the exception message if you expect that the user can understand and react based on this information)

• string Open(IReportDesignerUI designer);

This method expects a unique ID of the report selected by an end-user via your own UI dialog.
• XtraReport Load(string reportID, IReportSerializer designerReportSerializer);

This method passes the report ID that has been selected in the previous step and expects the actual report instance to be loaded and returned. You may or may not use the IReportSerializer  facilities to save or load a given report from a stream.

 • string Save(string reportID, IReportProvider reportProvider, bool saveAs, string reportTitle, IReportDesignerUI designer);

This method is intended to save the currently edited reports. 
The methods parameters are:
reportID is the unique ID of the edited report (null if it's a new report with no ID specified)
reportProvider allows you to get the actual report instance being edited and optionally rename it (a new name will be updated in the designer as well)
saveAs indicates which particular BarItem has been pressed ("Save" or "Save As")
reportTitle represents the actual report title (XtraReport.DisplayName)
designer is the actual report designer instance (the DevExpress.Xpf.Reports.UserDesigner.ReportDesigner class). Again, it's up to you whether to use it or not
__________________________________________________________________________________________________________________________________________

NOTE:
The WPF Report EUD is still in the beta stage (v.15.2.5); thus, there can be some limitations which are impossible to overcome at this moment (for example, there is no way to fill the SubReport's ReportSource drop-down window with the list of available reports). Moreover, some detail implementation may be changed on its official release. If you're experiencing any issues with running this sample or have additional questions, please contact our Support Team directly for further assistance.

Obtain labels from a datasource like the resources

$
0
0

This example illustrates how the labels for appointments could be obtained from a data source. This simple approach could be tailored to suit more complex requirements and implement the functionality described in the suggestion DS12188 (Labels - Obtain labels from a datasource like the resources).

Question Comments

Added By: .NET Developer at: 9/18/2012 11:44:43 AM    

The example you have provided here seems to be for WinForms only. Can you provide an example for the ASPxScheduler?

Added By: Bryan Meier at: 10/31/2012 8:28:03 PM    

And an example for Silverlight.

Added By: Emmanuel at: 2/4/2016 4:47:44 AM    Since Version 15.2 (not sure about minor version) the line
[VB.NET]
Dim aptLabel AsNew AppointmentLabel(color, dislayName, menuCaption)
is obsolete

[C#]
DimaptLabelAsAppointmentLabel=SchedStorage.Appointments.Labels.CreateNewLabel(key,displayName,menuCaption,color))
should be used instead

WinForms SpreadsheetControl API

$
0
0

This example demonstrates how to use the SpreadsheetControl API to programmatically manage spreadsheet documents, without the need for Microsoft Excel to be installed.

In particular, this sample introduces API properties and methods used to perform the following operations:

- Manage worksheets (activate, create, delete, rename, copy, adjust worksheet view, etc.)

- Manipulate rows and columns (insert, delete, copy rows and columns, adjust row height and column width, etc.)

- Manipulate cells and cell ranges (set cell values, add hyperlinks to cells, copy and merge cells), create, edit and copy cell comments

- Create formulas (use various functions and cell references in formulas, use names in formulas, create shared and array formulas, etc.)

- Format cells (set cell font, colors, alignment, borders, number format, etc.)

- Export the workbook to PDF

- Print the workbook

Question Comments

Added By: Rodney Stone 1 at: 12/1/2015 10:40:20 AM    

Cannot open form designer, get
The designer cannot process the code at line 32: DirectCast(Me.treeList1, System.ComponentModel.ISupportInitialize).BeginInit() The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified. Please remove any changes and try opening the designer again.

Change the DirectCast to Ctype

Added By: Andrey (DevExpress Support) at: 12/1/2015 11:10:45 PM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T319405: Error occurs in the E4655 example at design time. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Newblack at: 2/3/2016 4:43:27 PM    Hello.

How this example works?
I clicked and double-clicked the item in TreeList, but there is no change. 

I'm using DevExpress 15.2 version, Windows 7 Added By: George (DevExpress Support) at: 2/4/2016 5:30:29 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T342194: A double-click on an item in TreeList doesn't make any effect. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

GridView - How to create a custom tooltip for cells to display long text

$
0
0

This example demonstrates how to create a custom tooltip for data cells using the  PopupControl. The main idea is to assign a delegate method to the GridViewSettings.HtmlDataCellPrepared  property and handle the mouseover event to display a popup window.

[C#]
settings.HtmlDataCellPrepared=(s,e)=>{e.Cell.Attributes.Add("onmouseover",String.Format("OnMouseMove(this, event, '{0}');",e.KeyValue));};
[VB.NET]
settings.HtmlDataCellPrepared = Sub(s, e) e.Cell.Attributes.Add("onmouseover", String.Format("OnMouseMove(this, event, '{0}');", e.KeyValue))EndSub
[JScript]
var oldKey = null;function OnMouseMove(element, event, key){if(typeof GridView.cpTooltipList[key] != "undefined"&& oldKey != key){ oldKey = key; PopupControl.ShowAtPos(event.clientX, event.clientY); ToolTipLabel.SetText("Item " + key + "<br/>" + GridView.cpTooltipList[key]);}}


The GridViewSettings.CustomJSProperties  property is used to pass data to the client side. 

[C#]
settings.CustomJSProperties=(s,e)=>{MVCxGridViewgrid=sasMVCxGridView;intstartIndex=grid.VisibleStartIndex;intendIndex=grid.VisibleStartIndex+grid.SettingsPager.PageSize;varclientData=newDictionary<int,object>();for(inti=startIndex;i<endIndex;i++){varrowValues=grid.GetRowValues(i,newstring[]{"ID","Description"})asobject[];clientData.Add(Convert.ToInt32(rowValues[0]),rowValues[1]);}e.Properties.Add("cpTooltipList",clientData);};
[VB.NET]
settings.CustomJSProperties = Sub(s, e)Dim grid As MVCxGridView = TryCast(s, MVCxGridView)Dim startIndex AsInteger = grid.VisibleStartIndexDim endIndex AsInteger = grid.VisibleStartIndex + grid.SettingsPager.PageSizeDim clientData = New Dictionary(OfInteger, Object)()For i AsInteger = startIndex To endIndex - 1Dim rowValues = TryCast(grid.GetRowValues(i, NewString() {"ID", "Description"}), Object()) clientData.Add(Convert.ToInt32(rowValues(0)), rowValues(1))Next i e.Properties.Add("cpTooltipList", clientData)EndSub

DXRichEdit for Silverlight: How to use the RichEditDocumentServer to load file, modify it and save it in a different format

$
0
0

This example illustrates a simple use of RichEditDocumentServer.
After clicking the "Load a file" button it loads a file in Word 97-2003 format (DOC) , retrieves all images, displays them as a slide show and fills the text block with a plain text of the document.
After clicking the "Save a file" button, a custom text is inserted into the document's footer and the document is saved in OpenXml format (DOCX).

Question Comments

Added By: Gugui Florin at: 12/13/2013 1:56:26 AM    

Could you please update this example for the 13.2.5 version?

Viewing all 7205 articles
Browse latest View live


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