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

GridView - How to perform a custom client side unobtrusive validation for the EditForm template using a custom attribute

$
0
0

This example is based on the approach demonstrated in the E3744: How to enable unobtrusive validation for GridView using the EditForm template thread.
Perform the following steps to accomplish this task:
1) Create a ValidationAttribute class descendant.
2) Implement the IClientValidatable interface for this class to enable client side validation.
3) Write a custom adapter based on custom parameters that are passed from the server
4) Add a custom validation method

Below are some threads that may be helpful in accomplishing similar tasks:
Unobtrusive Client Validation in ASP.NET MVC 3
Unobtrusive client validation
Custom Unobtrusive jQuery Validation with Data Annotations in MVC 3
Creating custom unobtrusive file extension validation in ASP.NET MVC 3 and jQuery
GridView - How to enable unobtrusive validation for inline edit form


How to enable unobtrusive validation for GridView using the EditForm template

$
0
0

The example illustrates how to implement unobtrusive validation for GridView editors. Create an Edit Form template that contains a form and all necessary editors. Corresponding validation attributes will be rendered for the template.
The main requirement is that the updating should be performed using a helper script. In the script block, we prepare validation conditions and check them for the form (that is located within the Edit Form template). If all editors are valid, the grid's UpdateEdit command is invoked.

[JScript]
function UpdateGridView(){ PrepareValidationScripts();var validator = $.data($('#frmProduct')[0], 'validator');if(validator.form()) grid.UpdateEdit();}function PrepareValidationScripts(){var form = $('#frmProduct');if(form.executed)return; form.removeData("validator"); $.validator.unobtrusive.parse(document); form.executed = true;}

GridView - EditForm template - How to enable Microsoft MVC validation
GridView - How to perform a custom client side unobtrusive validation for the EditForm template using a custom attribute

Question Comments

Added By: K R at: 6/14/2013 5:30:59 AM    

Unable to download this example, error below

ICAP Error (icap_error)

 
An error occurred while performing an ICAP operation: Maximum file size exceeded; File: GetExample; Sub File: Content\Site.css; Vendor: Kaspersky Labs; Engine error code: 0x00000000; Engine version: 8.1.8.79; Pattern version: 130614.102700.10398212; Pattern date: 2013.06.14 10:27:00
There could be a network problem, the ICAP service may be misconfigured, or the ICAP server may have reported an error.

For assistance, contact your network support team.

Added By: Vasily (DevExpress Support) at: 6/17/2013 8:00:14 AM    

Hi,

We detected that you have posted the same question to ticket Q502783 (ICAP Error occurs when downloading example:"An error occurred while performing an ICAP operation: Maximum file size exceeded"). We kindly ask you to avoid posting duplicated issues in the future. This will save time, and will allow us to provide better service.

We will post our answer in ticket Q502783 (ICAP Error occurs when downloading example:"An error occurred while performing an ICAP operation: Maximum file size exceeded").

How to create a text editor that shows auto-completion suggestions in the popup (similar to entering email address in Outlook)

$
0
0

The current example demonstrates how to implement a text editor with the capability to show auto-complete suggestions for the word which is being typed.

Question Comments

Added By: Paola Cacciotti at: 9/23/2013 12:05:03 AM    

I have strange behavior when i used it in combination with Mask. I set MaskType = RegEx and I have an EditMask like this: (\p{Lu}|\d{1}).* meaning I want the first character upper. On execution when i type the first character into TextEditPopUp, the cursor go back to first position selecting the character. It’s like when i press the INS button on keyboard. I tested and it happens only when Mask is used.

Added By: Lisa Lang at: 11/28/2013 2:56:03 AM    

Do you have an example how to do this in WPF?
I tried it with the xpf LookUpEdit control by setting StyleSettings to MultiSelectLookUpEditStyleSettings, TextIsEditable = "True" and IncrementalFiltering="True". For the first value it works fine, but after entering the Separator ";" and start entering the second value auto-completion does no longer work.

Validation within a multi-page container

How to detect that the new page is being created and obtain the current page number within the BeforePrint event handler

$
0
0

Note: This example uses undocumented behavior of the XtraReports Suite, so we cannot guarantee that it will work correctly in the XtraReports Suite.

This example illustrates how to detect that a new page is being created and obtain the current page number within the BeforePrint event handler via the PrintingSystem.Document.PageCount property. Note that in this scenario, you should set the DetailBand.KeepTogether property to true.

Another (and more universal) approach to this task is demonstrated at E1952.

See also: AS16487.

Question Comments

Added By: Tobias Lachmann at: 2/8/2013 5:30:54 AM    

Ist it possible to get that work in 12.2?

Added By: Dean J. at: 5/17/2014 12:01:21 PM    

Is this still "undocumented".  It's not good to leave your customers for several years with this fear that it might stop working down the road.  I'm surprised that you haven't either changed this to "supported" or given an official solution.

ASPxGridView - How to display truncated text in a resizable column (using CSS)

$
0
0

This example demonstrates how to display truncated text in a resizable ASPxGridView column and show a full value as a tool tip.



1) Apply the following CSS class to column cells:


[CSS]
.truncated{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
[ASPx]
<dx:GridViewDataTextColumnFieldName="Description"VisibleIndex="2"><CellStyleCssClass="truncated"></CellStyle></dx:GridViewDataTextColumn>

2) Handle the ASPxGridView.HtmlDataCellPrepared event to set tool tips for the same DataCell via the e.Cell.ToolTip property.

 

See Also:
ASPxGridView - How to display a truncated text in a column

How to enable snap to the middle in the ZoomTrackBarControl 

$
0
0

This example demonstrates how to add snap to the middle in the the ZoomTrackBarControl control. 

First, we added two properties in the custom RepositoryItemZoomTrackBar: SnapToMiddleValue that allows you to enable or disable snapping and MiddleDistance that gives you the opportunity to change the distance (as a percent) from the middle of a trackbar when snapping takes effect.

How to import data to worksheet cells from different data sources and use tables

$
0
0

This example illustrates how to use the Worksheet.Import method to import data to worksheet cells from different data sources (arrays, lists and data tables), and how to format a range of cells as a table (refer to the How to: Create a Table document to get step-by-step instructions).

Question Comments

Added By: Piotr Tworek at: 5/19/2014 1:12:57 AM    

Hi
Good solution, but you can not import an ArrayList
for example

           Dim ListDataSource As New ArrayList()
           ListDataSource.Add(New Record(1, "Jane", 19))
           ListDataSource.Add(New Record(2, "Joe", 30))
           ListDataSource.Add(New Record(3, "Bill", 15))
           ListDataSource.Add(New Record(4, "Michael", 42))
Any idea?
Regards, Piotr


How to merge cells horizontally in GridView via the CustomDrawCell event

$
0
0

This example illustrates an approach that is similar to that one described in the following thread: How to merge cells horizontally in GridView.
The mentioned functionality is implemented via the GridView.CustomDrawCell event handling.

In addition, this example illustrates how to implement merged text scrolling.


Question Comments

Added By: VikV at: 5/23/2014 1:55:46 PM    

There is a problem with this code.  Unfortunately, the width of the merged cell is incorrectly calculated once you start resizing grid.  So, everything looks fine when you first show the grid, but as you make the grid *smaller*, eventually lines and text next to the merged cells are overwritten/hidden.  This is visible if you set the background of your merged cells to a color.

The reason for this is that the calculations of the "textRect" involve e.Bounds and column.Width, which do not seem to be correct as the grid is resizing.  Instead, you need to use the grid's GridViewInfo to get the GridCellInfo, which will then give you the proper bounds for the cell(s).  I used this method and got my grid to correctly resize.

So in essence, the problem is with GridColumn.Width not correctly being the cell's width when making the grid smaller.  For some reason, making the grid bigger (horizontally) does not have a bad effect, only making it smaller.

Added By: Andrew Ser (DevExpress Support) at: 5/26/2014 5:22:45 AM    

Hello,
Thank you for the cooperation. We will take your corrections into account and update this example soon.

How to create a single-page report to print a document on roll paper

$
0
0

This example demonstrates how to calculate the resulting report height and change its page size to place the report content into a single page. To accomplish this, create a document using the XtraReport.CreateDocument method, change the document page settings so the document contains a single page, and then adjust the page height by calculating the total height. The first adjustment is required to remove redundant Page headers and footers to calculate the resulting height more precisely.

How to create a DetailView with a custom set of properties

$
0
0

Suppose that it is necessary to provide a capability to work with documents. These documents can have various sets of fields, in various orders. To implement this scenario using standard XAF tools, it is necessary to create a lot of business classes, one for each kind of document. This solution doesn't allow the creation of a new document kind.


This example solves the described above task in the following way:


There is a Document class, which contains fields, common for all documents. It has an associated collection of document items, represented by the DocumentItemBase class and its descendants. To place document items into the Document DetailView, a custom property editor named DocumentItemsPropertyEditor is implemented. It is used for the Document.Items collection and draws a table with editors associated with document items. As a result, it is possible to customize editors shown in the DetailView at runtime.


Note that the example uses the InMemoryDataStoreProvider. To use another database, you need to modify the Session_Start event handler from the Global.asax.cs file.

See Also:
Implement Custom Property Editors

Question Comments

Added By: vguruv at: 7/5/2012 6:56:25 AM    

Does not work in edit mode on v12.1.4

Added By: Louis Z at: 5/26/2014 7:12:10 AM    

This example fails on 'New'.    Run, click new button.

NullReferenceExeption:  Object reference not set to an instance of an object.

private void CreateLayoutItems(LayoutControl layout) {
....
           for (int i = 0; i < itemsPerRow - columnIndex; i++) {
FAIL  -->              row.Add(new EmptySpaceItem());
           }

Added By: Anatol (DevExpress Support) at: 5/26/2014 10:23:37 AM    I have fixed the problem. Please see the updated example.

How to list all reports available in an application

$
0
0
This example demonstrates how to use System.Reflection methods to list all report types available in your application and then allow end-users to select and perform required actions on selected reports.

How to make DateEdit highlight certain dates like in DateNavigator

$
0
0

By default, the DateNavigator control allows you to set a collection of special dates and highlight them in bold font.

This example illustrates how to enable similar behavior in DateEdit.

First, it is necessary to create a DateEdit descendant and customize the "{dxet:DateEditThemeKey ResourceKey=CellButtonTemplate}" template.

Then, register two dependency properties - the SpecialDates property that contains a list of dates and the SpecialBorderStyle property that should contain a custom border style for date highlighting.

How to make the DXGrid view row template editable (the small sample of the DXGrid>Layout>Row Templates demo module)

$
0
0

The main idea is to create a DataRowTemplate that allows editing. In the sample, a row template is specified for several editors. To provide correct tabbing between editors, it's necessary to create a custom TableView where you override OnKeyDown and OnKeyUp methods.

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

$
0
0

Scenario:
In the How to connect to a remote data service instead of using a direct database connection example we described how to connect to the WCF service via console application.
If you want to take advantages of XPO data caching using this solution, the only difference is in using the ICachedDataStore interface and the CachedDataStoreService base service class that implements this interface.

Steps to implement
1.
Create a data service and console applications as described in the How to connect to a remote data service instead of using a direct database connection example.
2. Modify the service class as shown in the WCFService1\Service1 code file: use the CachedDataStoreService as base class, create a connection provide and data store.
3. Modify the web.configfile as shown in the WCFService1\web.config file.

There is no need to modify the client part since the service name has not been changed, and in addition, the “data caching domain” of our service is automatically detected by XPO.
It is easy to configure which tables should be cached and which ones shouldn't using the following code from the Service1 code file:

[C#]
DataCacheRootdataCacheRoot=newDataCacheRoot(dataStore)dataCacheRoot.Configure(newDataCacheConfiguration(DataCacheConfigurationCaching.InList,"Customer")MainDataStore=dataCacheRoot;DimdataCacheRootAsNewDataCacheRoot(dataStore)dataCacheRoot.Configure(NewDataCacheConfiguration(DataCacheConfigurationCaching.InList,"Customer"))MainDataStore=dataCacheRoot

This approach is useful for tables, which are frequently changed.

4. Create a data caching service based on the SqlDependency feature of the MS SQL Server. This approach is demonstrated in the WCFService2.Service1.xx file.

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 connect to a remote data service instead of using a direct database connection
How to implement a distributed object layer service working via WCF
How to connect to a remote data service from a Silverlight application

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


How to implement a radio column

$
0
0

This example demonstrates how to add an unbound grid column with a radio button (represented by a CheckEdit repository item) to provide a user with the ability to select one of the grid rows.

Question Comments

Added By: Dean J. at: 5/26/2014 1:07:29 PM    

This stops working if the user uses the autofilter row, because the previous row handle becomes wrong.
Steps:
1) in the description auto-filter row type characters that will cause only row #2 to show.
2) Select that row (radio button) for row #2
3) Clear the auto-filter criteria.  All rows are showing now and row #2 is still selected
4) Try to select the first row radio....it won't work.

How can you implement a radio column and allow the auto-filter row ???

Added By: Alexey Z (DevExpress Support) at: 5/27/2014 4:19:02 AM    Hello,

In order not to mix several questions within one thread, I will extract your question to a new ticket. Let us continue our discussion there How can you implement a radio column and allow the auto-filter row by using the E926 example .

How to locate detail view tabs in several lines

$
0
0

This example demonstrates how to create a custom GridControl by locating tabs in multiple lines.
First, we create a custom BaseTabControlViewInfo and override the IsMultiLine property to always return true.
Then, we create a custom GridView. Look at the How to create a GridView descendant class and register it for design-time use  example, which shows how to create custom GridView.
Also, we create a custom GridViewInfo and override the CalcScrollRect method to calculate new bounds for detail view.

How to modify the context menu of grid columns

$
0
0

The following example demonstrates how to customize the grid's context menu at runtime. For instance this sample demonstrates how to remove the default 'Show Column Chooser' menu item from the Column Context Menu, and add a custom item instead.

Question Comments

Added By: Sævar Kristinsson at: 2/6/2013 6:42:06 AM    

Hi, I would want to modify the column header context menu in design time. The only example I have found that touches this topic is this example or similar to it i.e. modifying the context menu in runtime. Could you guys give an example on how to do this in design time?

Added By: Thomas R Melinsky at: 5/27/2014 6:18:22 AM    

Is there a new version of this example for WPF that isn't event driven?

Added By: Ilya (DevExpress Support) at: 5/27/2014 9:08:19 AM    

Hi Thomas,
Currently, the approach demonstrated in his example is the appropriate way to customize the grid popup menu at runtime. Would you please clarify why it is not an option for you?

How to open Excel files in GridControl

$
0
0

This functionality is not supported out-of-the-box. Our GridControl, as well as any standard control, does not directly work with physical files. There are many reasons for this. For example, it is not possible to get notifications when some part of a physical file is changed. Thus, it will be necessary to reload the entire file each time the GridControl's content needs to be refreshed. Also, to save each change made in GridControl, it will be necessary to access this file again. Thus, dealing with physical files directly will be very slow.


That is why, to open an Excel file in GridControl, it is necessary to use an approach that you would use with a standard DataGridView control: populate a DataSet with data from an Excel file and then bind the grid control to this DataSet. To do this, you can use the Microsoft OLE DB Provider for Microsoft Jet. These solutions are described in the following articles:



Microsoft OLE DB Provider for Microsoft Jet

Import Excel File to DataSet - CodeProject


This example demonstrates this approach in action.

How to implement a custom map data provider

$
0
0

This example illustrates how to implement a custom map data provider class inherited from the MapDataProviderBase type. In the example, a custom MapTileSourceBase class is implemented to supply tile URLs from the OpenStreetMap source.

Question Comments

Added By: Mohsin Dhalayat 1 at: 5/27/2014 10:54:33 PM    

Is there any example which shows google maps instead of openstreet maps?

Added By: Alex (DevExpress Support) at: 5/27/2014 11:14:33 PM    Please note that a possible solution does not comply with Google Maps Terms of Service: you can use it for demo purposes only (see Map Control With Google maps).
Viewing all 7205 articles
Browse latest View live


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