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

How to customize PrintDialog and show the default .Net PrintDialog

$
0
0

This example illustrates how to customize PrintDialog in PrintPreview.

 

Note :

To show the default .Net Print Dialog instead of our PrintDialog, execute the following code :

[C#]

DevExpress.XtraEditors.Preview.PrintDialogRunner.Instance = DevExpress.XtraEditors.Preview.DefaultPrintDialogRunner();

 

 


How to store data to a local file using PhoneGap API

$
0
0

This example demonstrates how to store data to a local file using PhoneGap API. To access a corresponding API, it is necessary to add a link to the cordova.js file.

This example can be tested only on a mobile device.

See also:
PhoneGap Documentation - File
How to build a native package in Visual Studio
How to test PhoneGap API via the Courier tool

Question Comments

Added By: Andrea Tatone at: 7/25/2013 11:14:40 AM    

Many thanks for the example. I've tried it in the simulator and the courier, but it doesn't work (i'm working on a android 2.3.4 device). It fails with the message "File system is not accessible", either in read and write. Is there anything I can do?

Added By: Nikolai (DevExpress Support) at: 7/25/2013 11:18:07 PM    

Hi Andrea,

I have created a separate ticket regarding this issue. Please post all messages here Q377803.

Added By: Rakesh Parab at: 5/28/2014 12:15:35 AM    

plz help me 4.......
how to store .csv file to particular path in mobile like /mnt/sdcard/csvfiles .
???

Added By: Nikolai (DevExpress Support) at: 5/28/2014 7:09:53 AM    Hi Rakesh,

I have created a separate ticket for this issue How to store a file to a particular folder. Please post all comments in this ticket.

How to connect to a remote data service instead of using a direct database connection

$
0
0

Scenario

In this example, we will create a WCF IDataStore service that will be used by our client (Console Application) as a data layer. Instead of the direct connection to the database, our client will connect to a remote service, which is way more secure and thus important in many enterprise scenarios as database connection settings are not exposed to the client.


Steps to implement

1. Create a new WCF Service Application project and add references to the DevExpress.Data and DevExpress.Xpo assemblies and remove files with auto-generated interfaces for the service.

2. Modify the service class as shown in the Service1 file. This service initializes a connection provider and stores it in the static DataStore property, which is then used by the base DataStoreService class.

3. Change some binding properties as shown in the example's web.config file. At this stage, the service part is ready to work and we need to implement a client to consume data from our data store service (for demonstration purposes, we will create a Console Application).

4. Add the Console Application into the existing solution.

5. Add a new code file for a Customer class using the DevExpress v1X.X ORM Persistent Object item template. See a code of Customer class in the ConsoleApplication\Customer code file.

6. Pass the address of our service into the GetDataLayer method of the XpoDefault class. For this, modify the Main method of the Console Application as shown in the ConsoleApplication\Program code file. Please note that the port number in the connection string may be different. You can check it in the properties of the service project in the Solution Explorer:


As a result, we will see the following output:

Important notes
If you are using an XAF client, then in the simplest case, you can just set the XafApplication.ConnectionString to the address of your data store service (http://localhost:55777/Service1.svc). Refer to the Connect an XAF Application to a Database Provider help article for more details.

See Also:
How to use XPO with a Web Service
Transferring Data via WCF Services
How to connect to a remote data service from a Silverlight application

How to create a data caching service that helps improve performance in distributed applications

How to implement a distributed object layer service working via WCF

How to connect to remote data store and configure WCF end point programmatically

 

Question Comments

Added By: NBT Developers at: 5/28/2014 10:39:32 AM    

FYI on this part "If you are using an XAF client, then in the simplest case, you can just set the XafApplication.ConnectionString to the address of your data store service (http://localhost:55777/Service1.svc). "

Literally do this:
WebApplication.Instance.ConnectionString = "http://localhost:55777/Service1.svc";

XpoDefault.DataLayer = XpoDefault.GetDataLayer("http://localhost:55777/Service1.svc",
           AutoCreateOption.DatabaseAndSchema);

           XpoDefault.Session = null;

           using (UnitOfWork uow = new UnitOfWork())
           {
           }

How to enable GridView to highlight text, matching text typed in the AutoFilterRow, in cells

$
0
0

This sample illustrates how to enable GridView to highlight text, matching text typed in the AutoFilterRow. For this we used the GridView's CustomDrawCell event and the DrawMultiColorString method provided by the XPaint.Graphics class.

Question Comments

Added By: PHN at: 5/28/2014 10:03:58 AM    

Hi,
Can you provide an example for ASPxGridView?
Thanks!

Added By: Ekaterina (DevExpress Support) at: 5/28/2014 10:48:14 PM    Hi,

I've created the  Can you provide the E3134 example for ASPxGridView? ticket on your behalf. Let discuss your question there.

How to use the ASPxGridView control (with the enabled vertical scrollbar) in a Full Screen mode (100% browser Width and Height)

$
0
0

This example demonstrates how to resize the ASPxGridView control based on the browser window size.

See Also:
How to use the ASPxPageControl control in a Full Screen mode (100% browser Width and Height)

Question Comments

Added By: neuDev33 at: 5/16/2012 11:48:45 AM    

I'm copy + pasting this code, but the height does not increase to cover the parent control

Added By: just wqq at: 9/18/2012 7:45:13 PM    

DevExpress.Web.ASPxGridView.v8.3 can do this

Added By: Michelle Young at: 7/31/2013 7:46:42 AM    

Visual studio says the code behind method is obsolete and you should now use RegisterBaseScript instead.

Added By: Yevgeniy Reznik at: 7/31/2013 8:45:41 PM    

Can you please update to the latest version of DevExpress?

Added By: Honesto Manlig at: 5/28/2014 9:03:24 PM    

How can I have the columns to be of width they need to be. Except for the last column to be the only one that grows to fill the rest of the gridview. For example, if there's three columns, if first column contains  text, it'll get as wide as it needs to so it does not wrap the text, then second column is a checkbox, so can always be same width, then the last column must get wide enough so that it fills the rest of the grid's width.

Added By: Artem (DevExpress Support) at: 5/29/2014 12:01:42 AM    Hello,

I've moved your question to a separate thread created on your behalf:
How to use the ASPxGridView control (with the enabled vertical scrollbar) in a Full Screen mode (100% browser Width and Height)
Please refer to it for further correspondence.

How to apply the running total feature for a specific data field only

$
0
0

This example demonstrates how to show running totals for one field, while displaying typical total summaries for another.

See Also:
Add the capability to specify data fields for the RunningTotals feature 

Question Comments

Added By: Xavier Codina at: 3/14/2014 12:17:55 PM    

This example don't show running totals. The ProductAmount value and ProductAmount Running value are identical.
Please, fix this.

Thanks,
Xavi Codina

Added By: Constant (DevExpress Support) at: 3/20/2014 6:38:13 AM    

I have just checked this example, but have not noticed any issues. Note that the Running Total values are calculated by the "ProductName" fields. Each row cell value shows summary values calculated by all previous rows.

How to implement a Document Preview in a Silverlight application

$
0
0

This example demonstrates how you can add XtraReport to a Silverlight application and show its Document Preview from where it can be printed and/or exported to a variety of popular formats (notably PDF, HTML, MHT, RTF, TXT, CSV, XLS, XLSX, and XPS).

A document exporting is performed via a reporting service deployed on the server-side.

This sample contains two projects:

- SilverlightApplication1, providing functionality for the client-side Document Preview;

- SilverlightApplication1.Web, with the report service hosted on the server to generate reports.

NOTE: For this example to work correctly, SilverlightApplication1.Web must be set as a "Start Up Project" and the SilverlightApplication1TestPage.aspx must be set as a "Start Page".

See also:
-
How to use XtraReports in a Silverlight application using XPO as data source;
- How to invoke a Silverlight Report Designer for a report bound using XPO;
- How to use the Silverlight report designer.

How to remove standard bar items and add custom ones to the DocumentPreview toolbar


How to share the same SiteMap between ASPxMenu and ASPxSiteMapControl placed within ASPxMenu.SubMenuTemplate

$
0
0

This example illustrates how to share the same SiteMap between ASPxMenu and ASPxSiteMapControl placed to show information from different SiteMap node levels. Here are steps you need to execute:

- Place ASPxSiteMapControl within ASPxMenu.SubMenuTemplate;
- Specify the ASPxSiteMapControl.DataSource property. ASPxSiteMapControl and ASPxMenu should have different ASPxSiteMapDataSource;
- Handle the ASPxSiteMapControl.DataBinding event;
- Define the ASPxSiteMapDataSource.StartingNodeUrl property according to the parent menu node's NavigateUrl:

Question Comments

Added By: Anton Logvenchev at: 5/29/2014 3:44:13 AM    

Goof example. But when I click at the any mainmenu ("SubCategoryA" for example) I got the error - 404 - File or directory not found.

Added By: Helen (DevExpress Support) at: 5/29/2014 5:24:16 AM    

Hello Anton,

Thank you for the feedback. The cause of the problem is that the urls defined in the xml file do not refer to real pages. I've replaced them with dummy code that does not raise 404 error.

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

How to track filter criteria changes in the unbound FilterControl

$
0
0

By default, the FilterControl's FilterCriteria property is updated only after the ApplyFilter method has been called, while the ActualFilterCriteria property does not send notifications when the user changes the filter.

This sample project shows how to force an unbound FilterControl to update its FilterCriteria property and bind another control or a view model to this property.

 

Use only one scroll bar for a grid with multiple master/detail levels.

$
0
0

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 AM    

Does 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.

ASPxSplitter - How to manipulate client-side objects inside a pane with the specified ContentUrl property

$
0
0

This example demonstrates how to manipulate the client-side programmatic objects inside ASPxSplitter's pane with a specified ContentUrl property.

- Get the content IFrame from ASPxSplitter's pane with a specified ContentUrl property viathe ASPxClientSplitterPane.GetContentUrlmethod;
- Get the underlying content window object of this IFrame via the contentWindowproperty;
- Get the required object from this window and manipulate it.

How to set ASPxTextBox.Text inside a pane with a specified ContentUrl property.

ContentPageWithTextbox.aspx:

[ASPx]
<dx:ASPxTextBoxID="tbContent"runat="server"Width="170px"ClientInstanceName="clientTbContent"></dx:ASPxTextBox>


Default.aspx:

[ASPx]
<dx:ASPxSplitterID="splt"runat="server"ClientInstanceName="splitter"><Panes><dx:SplitterPane><ContentCollection><dx:SplitterContentControlID="SplitterContentControl1"runat="server"><dx:ASPxComboBoxID="cmb"runat="server"ClientInstanceName="clientComboBox"><Items> ... </Items><ClientSideEventsSelectedIndexChanged="OnSelectedIndexChanged"/></dx:ASPxComboBox></dx:SplitterContentControl></ContentCollection></dx:SplitterPane><dx:SplitterPaneContentUrl="~/ContentPageWithTextbox.aspx"Name="pnExternalPage"></dx:SplitterPane></Panes></dx:ASPxSplitter>

[JScript]
function OnSelectedIndexChanged(s, e){var contentIFrame = splitter.GetPaneByName("pnExternalPage").GetContentIFrame();var contentIFrameWindow = contentIFrame.contentWindow;var contentTextBox = contentIFrameWindow.clientTbContent;if(contentTextBox) contentTextBox.SetText(s.GetText());}

See Also:
E3614: ASPxSplitter - How to return a value from a page specified via SplitterPane.ContentUrl

How to export the colored ASPxGridView

$
0
0

This example demonstrated how to handle the ASPxGridViewExporter.RenderBrick Event to paint the exported ASPxGridView.

Question Comments

Added By: Smitha at: 5/30/2014 9:37:00 AM    

But how do I make the font to bold and also underline the text. If I do , it doesn't work. I get the error that the property is a read only one.
e.BrickStyle.Font.Bold = true;
e.BrickStyle.Font.Underline = true;

How to change a row style based on a column value

$
0
0

This example demonstrates how to dynamically change the row's appearance based on a specific column's value


How to search for objects by using all the properties or by using more complex criteria

$
0
0

This example provides a possible workaround for the Filtering - Support searching objects by a string through all the properties (or a set of properties) or by more complex criteria suggestion.
The Dennis.Search.Win module, shown in the example, provides API to create a non-persistent object that can be used to search by properties of a business class. Such a non-persistent search-object should implement the ISearchObject contract. By default, it's supported by the abstract and generic SearchObjectBase class in the module. Search-objects are shown in a Detail View with the help of the SearchObjectViewController. To compose a search criteria, a specific SearchObjectPropertyEditor is used (it contains the Search and Clear buttons).
An example use of the implemented module is illustrated in the WinSolution.Module.Win module. There is a ProductSearchObject class that is inherited from the base SearchObjectBase class. If necessary, you can create several search objects for one business class. In UI, all search objects will be listed in a drop-down list in the toolbar of a View of your business class. Download and run the attached example to see how this works in action.
(Take special note of the SearchObjectBase class implementation, because it asynchronously loads search results of a specific type from the data store into the Search Results nested List View.)

See Also:
How to allow users to create filter via the criteria editor before previewing a report
How to use Criteria Property Editors

Question Comments

Added By: Taradanov at: 6/17/2012 8:28:29 AM    

Can you provide Web editor for this example, please?

Added By: Gavin Lipeng Ma at: 3/20/2013 7:50:39 PM    

Also need a web solution.Could you please provide a web solution for this ?

Added By: kenngo at: 5/30/2014 10:49:42 PM    

The SearchObjectBase[Product]_SearchResults_ListView in the Model Editor is autogenerated? How is the search result link to this view?

How to display a login view as a popup window during navigation between views

$
0
0

This approach can be applied starting with 13.2.9

This example demonstrates how to check whether the user is logged in and display a login view when it is necessary during navigation.

It is necessary to perform the following steps to accomplish this task:

1. Add a new view and place a dxPopup in it.

2. Implement the required logic for this view in a corresponding view model.

3. Handle the HtmlApplication.initialized event. In this event handler, get the login view template using the HtmlApplication.getViewTemplate method and add the view to the view port. This will allow you to display its internal popup using options from its view model.

4. Bind the login view model to the view markup using Knockout.

5. Declare a global variable for determining when a user is logged in. In this example we set this option to false by default, and we will set it to true when a user is logged in. This variable can be accessed from any part of the application and we can change its value in the login view model.

6. Handle the HtmlApplication.navigating event. In this event handler, we can get a view info (see HtmlApplication.getViewTemplateInfo) for the navigated view and check user credentials if necessary. For this purpose, we added the secure option to those views that should not be displayed for unauthorized users. If the user unauthorized, we can call a method from the login view model to display dxPopup from the login view. Moreover, you can cancel navigation by setting the cancel parameter of the event handler to true.

See also:
How to send authenticated requests to the OData service

Question Comments

Added By: Alexandre Henriques at: 4/28/2014 7:36:44 AM    

How do I make this piece of code in version 13.2.7?

app.initialized.add(function() {
       var $view = app.getViewTemplate("LogOnPopup");
       $view.appendTo(".dx-viewport");
       LogOnAsPopupView.loggedOn = ko.observable(false);
       LogOnAsPopupView.logOnPopupViewModel = LogOnAsPopupView.LogOnPopup();
       ko.applyBindings(LogOnAsPopupView.logOnPopupViewModel, $view[0]);
   });

Added By: Nikolai (DevExpress Support) at: 4/28/2014 11:00:20 PM    Hi Alexandre,

I have created a separate ticket for this issue. Please post comments to the How to display a login view as a popup window during navigation between views (13.2.7) ticket.Added By: Faraz Faheem at: 6/1/2014 3:28:54 AM    

Im having error on initialized event. Error says 'Error: cannot ready property 'add' of undefined' on app.initialized.add(funtion() { line.

Please help me

Added By: Faraz Faheem at: 6/1/2014 3:52:38 AM    

I just upgraded my project to 13.2.9 by project converter and viola everything works.

Thanks for the self-explanatory post.

How to save/print a selected page of a report in a web application

$
0
0

This example illustrates how to save or print current page of the report displayed in the ASPxDocumentViewer control

WPF Spreadsheet Chart API

$
0
0
This example demonstrates how to use the SpreadsheetControl Chart API to programmatically manage charts in worksheets.
The application includes the RichEditControl (at the top) used to display and edit the code and the SpreadsheetControl (at the bottom) which shows the result of code execution.
You can modify the code and watch the result. The code is executed every two seconds. 

GridView - How to implement and edit many-to-many relations in MVC

$
0
0

This example demonstrates a simple implementation of a many-to-many relationship. 
The ORM for the data layer is Entity Framework.

In this example, clicking on the "Link" button will add a relation between the selected User and the selected Role. Clicking the "Unlink" button will remove this relation.

Viewing all 7205 articles
Browse latest View live