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

How to use XPO in ASP.NET MVC3 / MVC4 application (Razor)

$
0
0

This example demonstrating a simple ASP.NET MVC3 / MVC4 application using XPO as Data Access Layer.

See also: How to use XPO in an ASP.NET MVC application

Question Comments

Added By: TPS Programmer at: 11/3/2014 2:38:52 AM    

how to convert this syntaks

@model IEnumerable<CustomerViewModel>
@Html.Partial("IndexPartial", Model);

into vb syntax ?

Added By: TPS Programmer at: 11/3/2014 2:40:10 AM    

almost forget, because in VB source code, index.cshtml still in C#, not in VBHTML

Added By: Anthony (DevExpress Support) at: 11/3/2014 5:01:27 AM    

Hi,

The code would be as follows:

[VB.NET]
@ModelType IEnumerable(Of CustomerViewModel) @Html.Partial("IndexPartial", Model)

As for the example, we will correct the syntax as soon as possible.

Added By: Ken Byington 1 at: 5/26/2015 11:16:52 AM    

It sure would be nice if you would upgrade your examples to the current version of MircoSoft and DevExpress products.  When I tried to run the Example from here in VS 2013 using MVC 4, it had to convert to the current version and then I had to play with references and I finally ended up with this stack dump:
System.TypeInitializationException was unhandled by user code
 HResult=-2146233036
 Message=The type initializer for 'XpoHelper' threw an exception.
 Source=DevExpressMvcApplication
 TypeName=XpoHelper
 StackTrace:
      at XpoHelper.GetNewUnitOfWork()
      at DevExpressMvcApplication.Controllers.BaseXpoController`1.CreateSession() in c:\Visual Studios\DevExpressMvcApplication\Controllers\BaseXpoController.cs:line 18
      at DevExpressMvcApplication.Controllers.BaseXpoController`1..ctor() in c:\Visual Studios\DevExpressMvcApplication\Controllers\BaseXpoController.cs:line 10
      at DevExpressMvcApplication.Controllers.CustomersController..ctor()
 InnerException: DevExpress.Xpo.DB.Exceptions.UnableToOpenDatabaseException
      HResult=-2146233088
      Message=Unable to open database. Connection string: 'data source=.;initial catalog=XPOMVXExampleEditable;integrated security=sspi;'; Error: 'System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) ---> System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
  at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
  at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
  at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover, SqlAuthenticationMethod authType)
  at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
  at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
  at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
  at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken)
  at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
  at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
  at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
  at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
  at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
  at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
  at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
  at System.Data.SqlClient.SqlConnection.Open()
  at DevExpress.Xpo.DB.MSSqlConnectionProvider.CreateDataBase(SqlConnection conn)
ClientConnectionId:00000000-0000-0000-0000-000000000000
Error Number:2,State:0,Class:20'
      Source=DevExpress.Xpo.v14.2
      StackTrace:
           at DevExpress.Xpo.DB.MSSqlConnectionProvider.CreateDataBase(SqlConnection conn)
           at DevExpress.Xpo.DB.MSSqlConnectionProvider.CreateDataBase()
           at DevExpress.Xpo.DB.ConnectionProviderSql..ctor(IDbConnection connection, AutoCreateOption autoCreateOption)
           at DevExpress.Xpo.DB.MSSqlConnectionProvider..ctor(IDbConnection connection, AutoCreateOption autoCreateOption)
           at DevExpress.Xpo.DB.MSSqlConnectionProvider.CreateProviderFromString(String connectionString, AutoCreateOption autoCreateOption, IDisposable[]& objectsToDisposeOnDisconnect)
           at DevExpress.Xpo.DB.DataStoreBase.QueryDataStore(String providerType, String connectionString, AutoCreateOption defaultAutoCreateOption, IDisposable[]& objectsToDisposeOnDisconnect)
           at DevExpress.Xpo.XpoDefault.GetConnectionProvider(String connectionString, AutoCreateOption defaultAutoCreateOption, IDisposable[]& objectsToDisposeOnDisconnect)
           at DevExpress.Xpo.XpoDefault.GetDataLayer(String connectionString, XPDictionary dictionary, AutoCreateOption defaultAutoCreateOption, IDisposable[]& objectsToDisposeOnDisconnect)
           at DevExpress.Xpo.XpoDefault.GetDataLayer(String connectionString, AutoCreateOption defaultAutoCreateOption)
           at XpoHelper.UpdateDatabase() in c:\Visual Studios\DevExpressMvcApplication\Helpers\XpoHelper.cs:line 48
           at XpoHelper..cctor() in c:\Visual Studios\DevExpressMvcApplication\Helpers\XpoHelper.cs:line 12
      InnerException: System.Data.SqlClient.SqlException
           HResult=-2146232060
           Message=A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
           Source=.Net SqlClient Data Provider
           ErrorCode=-2146232060
           Class=20
           LineNumber=0
           Number=2
           Server=""
           State=0
           StackTrace:
                at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
                at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
                at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover, SqlAuthenticationMethod authType)
                at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
                at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
                at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
                at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken)
                at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
                at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
                at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
                at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
                at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
                at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
                at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
                at System.Data.SqlClient.SqlConnection.Open()
                at DevExpress.Xpo.DB.MSSqlConnectionProvider.CreateDataBase(SqlConnection conn)
           InnerException: System.ComponentModel.Win32Exception
                HResult=-2147467259
                Message=The system cannot find the file specified
                ErrorCode=-2147467259
                NativeErrorCode=2
                InnerException:

Can you post an already migrated version so I don't have to waste more hours?

Added By: Anthony (DevExpress Support) at: 5/29/2015 3:34:37 AM    Hi Larry,

Thank you for bringing our attention to this. We will update the sample soon.

How to save/load the layout data of the grouped ASPxGridView

$
0
0

This example demonstrates how to save/load the layout data of the grouped and expanded rows during callbacks. Pay attention to the following features:

- The Dictionary<string, string> contains grouped grid's layouts saved by the user. This Dictionary is kept in a Session.
- It is possible to load the last saved layout from by clicking the "Load Layout" button.

How to customize the New Report Wizard (introduced in the 2014 vol.1 release) in the End-User Designer

$
0
0

This sample illustrates how to customize the wizard in the End-User Designer.

Question Comments

Added By: Jon 9 at: 10/23/2014 5:08:13 AM    

Is there any further documentation on how to customize the new report wizard. This sample code would really benefit from some comments... I can see why it has attracted down votes - it isn't really sufficient.

Added By: Ingvar (DevExpress Support) at: 10/23/2014 6:28:50 AM    Hi Jon,

I agree with you that we need to prepare documentation related to our Report Wizard. I have created a separate request and forwarded it to our developers. You can track our progress in the following ticket:
Documentation - Provide informative help topics on how to customize Report Wizard introduced in v14.1Added By: Jon 9 at: 10/23/2014 6:37:12 AM    

Great, thanks! Will look forward to it.

Added By: Scott Bogash 1 at: 12/5/2014 9:19:21 AM    

Can you please update this example to work with v2014 vol 2.3.  Thank you

Added By: Scott Bogash 1 at: 12/30/2014 11:43:37 AM    

Can you please update this example to work with v2014 vol 2.3.  Thank you

Added By: Andrew L (DevExpress Support) at: 12/30/2014 1:09:06 PM    

Hello Scott,

We are working hard on this problem and we will do our best to prepare this sample to work with our next minor release, 2014.2.4.

Added By: Andrew L (DevExpress Support) at: 1/21/2015 1:29:16 AM    

Hello Scott,

We have found an issue in our 2014.2.4 release, which prevents us from publishing the sample. Please install the hot fix provided in the The Wizard Customization example (T140683) cannot be compiled thread and review the updated samples (in that thread).

Added By: Michael Vasiliev at: 3/24/2016 9:19:30 AM    Hi guys.

Can you please tell me how can I create a custom view for custom wizard?
I noticed that the views in the example (ChoosePersonsPageView2) were created  in Designer.
And they have specific controls (DevExpress.DataAccess.UI.Wizard.BackButton).
But I can't find them in Toolbox.Added By: Jannet (DevExpress Support) at: 3/24/2016 10:20:03 AM    

Hello,
To process your recent post more efficiently, I created a separate ticket on your behalf: T360326: How to create a custom view for custom wizard. This ticket is currently in our processing queue and will be addressed shortly.

GridView - How to update an associated column editor in the Edit Form when the ComboBox column editor value is modified

$
0
0
This as an MVC version of the T359598 - ASPxGridView - How to update an associated column editor in the Edit Form when the GridViewDataComboBoxColumn editor value is modified code example. A custom callback to the server is handled via the jQuery.ajax function (e.g., see E4063 - How to use the jQuery.ajax function with DevExpress MVC Extensions)

Note that we have used the techniques from the following webpages in this example:

Passing Values to a Controller Action through Callbacks
T191698 - How to isolate extension settings into separate helper class and share a single partial view to display multiple extensions

Actual updating of the underlying datasource is not implemented in this example. Please review the E3983 - GridView - How to edit in memory data source code example if you are interested in this scenario.

How to refer to a client-side control within a UserControl, if there is more than one UserControl instance on a page

$
0
0

This is an example for article How to refer to a client-side control within a UserControl. There is a UserControl with an ASPxPopupControl control. Two instances of the UserControl are put on a page. Each UserControl instance deals with its own popup control. Note the dynamically generated handler for the button's client-side Click event and EditPropertiesBase.ClientInstanceName in WebUserControl.ascx code behind.

See Also:
Client-Side API Availability for a Web Control
K18282 - The general technique of using the Init/Load event handler

Question Comments

Added By: Jay Johnson at: 6/10/2015 2:30:42 PM    

Trying this with an ASPxRadioButton and getting "Databinding expressions are only supported on objects that have a DataBinding event.  DevExpress.Web.CheckEditClientSideEvents does not have a DataBinding event."

Any ideas?

Added By: Jay Johnson at: 6/10/2015 2:31:38 PM    

<dx:ASPxRadioButton ID="optNo" runat="server" Text="No" GroupName="Answer" Layout="Flow" Theme="MetropolisBlue" >
       <ClientSideEvents CheckedChanged= '<%#GetButtonClickHandler()%>' />
   </dx:ASPxRadioButton>

Added By: Larry (DevExpress Support) at: 6/10/2015 11:37:58 PM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T254117: The "Databinding expressions are only supported on objects that have a DataBinding event. DevExpress.Web.CheckEditClientSideEvents does not have a DataBinding event." error occurs. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Jaime Castello at: 8/18/2015 11:53:20 PM    

This works for controls where you can bind the function. However it not explain how to bind the javascript function on grid callbacks.

If you have this situation, I have no idea how to adapt openComisarioDetalle:

<script id="dxss_personaluploaderscript" type="text/javascript">
function gridComisionadosCustomButtonClick(s, e) {
gridcomisarios.GetRowValues(e.visibleIndex, "idrecord;name;surname", openComisarioDetalle);
}
function openComisarioDetalle(values) {
//some code here
}
</script>

<dx:ASPxGridView ID="gridcomisarios" runat="server" AutoGenerateColumns="False"
                   Width="100%" EnableTheming="True" ClientInstanceName="gridcomisarios" EnableViewState="False" Cursor="pointer">
                   <ClientSideEvents CustomButtonClick="function(s, e) { gridComisionadosCustomButtonClick(s, e); }" />

Added By: Paul (DevExpress Support) at: 8/19/2015 1:43:13 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T279924: How to create a javascript function in code behind. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

GridView - How to restore the expanded group rows state after a page is refreshed

ASPxGridView - How to restore the expanded group rows state after a page is refreshed

How to provide data to a grid via WCF Web Services in server mode

$
0
0

The following example demonstrates how to use WCF (Windows Communication Foundation) to provide data for the DXGrid control. Note that in this case the DXGrid control works in server mode. This guarantees the best possible performance with large datasources for passing data from a server to a client-side DXGrid control.

Important Note: For version 11 and lower, this example makes use of the open source InterLINQ library. Therefore, if you want to use it in your applications, you should review its license. For a detailed description of this approach, refer to the following Knowledge Base article: K18300

Question Comments

Added By: annalisa giacoponi at: 11/25/2013 6:54:21 AM    

How can I pass one or more parameters at the CreateHandler method to filter query result?
thanks

Added By: Alexander Ch (DevExpress Support) at: 11/25/2013 11:53:50 PM    

Hi Annalisa,

I've created a separate ticket on your behalf: http://www.devexpress.com/Support/Center/Question/Details/Q463300. We will answer you there.

Thanks


How to force the ComboBoxEdit to post the selected value when the Tab key is pressed

$
0
0

This example demonstrates how to create a ComboBoxEdit that posts a value selected in the popup when the Tab key is pressed.

To enable this feature, we have created a ComboBoxEdit class descendant and overridden its ProcessPopupKeyDown method. In this method, we check which key was pressed by a user (we obtain it from the KeyEventArgs.Key property). If it's "Tab", we forcibly close the popup by using the ClosePopup method:

[C#]
protectedoverrideboolProcessPopupKeyDown(KeyEventArgse){if(e.Key==Key.Tab){if(IsPopupOpen)ClosePopup(PopupCloseMode.Normal);}returnbase.ProcessPopupKeyDown(e);}
Question Comments

Added By: John Genske at: 3/25/2016 2:14:50 PM    How do you achieve the same thing in the grid column?

Navigation - How to implement callback-based navigation in the project generated by the Template Gallery

$
0
0
Problem:

I created a new MVC application by using the ASP.NET MVC Web Application template from the Template Gallery (see also: Project Wizard). After that, I added several custom partial views and want to load them dynamically when an end-user clicks a specific item of the NavBar extension in the ContentLeftPartialView.cshtml partial view. What should I do?


Solution:
Here are the most straightforward approaches to solving this problem:

1) Load the required partial views via  the jQuery.ajax function by using the approach illustrated in the E4063 - How to use the jQuery.ajax function with DevExpress MVC Extensions code example. 

2) Or, use our CallbackPanel extension and the MVCxClientCallbackPanel.PerformCallback(Object) method.

In both scenarios, you need to handle the client-side ASPxClientNavBar.ItemClick event and initiate a parametrized callback (ajax or CallbackPanel-specific) to the appropriate controller's action method on the server side and get the required partial view.

Note that if you are working with regular (full) views instead of partial views, follow the approaches described in the KA18732 - How to open external Page / View in a Splitter Pane KB article and examples linked to this article.

See Also:
KA18923 - The SetContent method - How to define a content using different syntax constructions
Menu - How to load a content using callbacks on a menu item click based on the DevExpress Project template

Menu - How to load a content using callbacks on a menu item click based on the DevExpress Project Template

How to handle DiagramControl events to save diagrams to a database instead of a file system

$
0
0
This example demonstrates how to open and save diagrams to a custom storage (e.g., a database) instead of a file system. In the example, the following events are used to implement this functionality:

ShowingOpenDialog - This event fires before the standard Open dialog is shown and allows you to customize the dialog options or replace the standard dialog with a custom one. You can also cancel the Open operation by setting the e.Cancel parameter to true.
ShowingSaveDialog - Similarly to the ShowingOpenDialog event, the ShowingSaveDialog event allows you to customize the standard Save dialog in DiagramControl or replace it with a custom one. Setting the e.Cancel parameter to true will cancel the Save operation.
CustomLoadDocument - This event fires after a user selected a document in the Open dialog or the DocumentSource property was set in code. The event exposes the selected document source (e.g., a document name or a file stream) through thee.DocumentSource property and allows you to implement your own loading logic. For example, you can retrieve a diagram file from a database and load it into DiagramControl using the LoadDocument property (as demonstrated in the example) or populate the diagram with items manually. After implementing your custom loading logic, set the e.Handled parameter to true, so that DiagramControl does not load the previously selected document source.
CustomSaveDocument - The CustomSaveDocument event allows you to specify custom saving logic for your diagram. The event fires after the Save operation was initiated and selection was made in the Save dialog (if there was a dialog). Thee.DocumentSource property in the event args specifies the default location (file name, stream, etc.) where the diagram will be saved. You can set the e.Handled parameter to true to cancel the standard saving logic and implement your custom one. For example, save the diagram to a stream using the SaveDocument method as demonstrated in the example or iterate through diagram items manually and read required information.

How to handle DiagramControl events to save diagrams to a database instead of a file system

$
0
0
This example demonstrates how to open and save diagrams to a custom storage (e.g., a database) instead of a file system. In the example, the following events are used to implement this functionality:

ShowingOpenDialog - This event fires before the standard Open dialog is shown and allows you to customize the dialog options or replace the standard dialog with a custom one. You can also cancel the Open operation by setting the e.Cancel parameter to true.
ShowingSaveDialog - Similarly to the ShowingOpenDialog event, the ShowingSaveDialog event allows you to customize the standard Save dialog in DiagramControl or replace it with a custom one. Setting the e.Cancel parameter to true will cancel the Save operation.
CustomLoadDocument - This event fires after a user selected a document in the Open dialog or the DocumentSource property was set in code. The event exposes the selected document source (e.g., a document name or a file stream) through the e.DocumentSource property and allows you to implement your own loading logic. For example, you can retrieve a diagram file from a database and load it into DiagramControl using the LoadDocument property (as demonstrated in the example) or populate the diagram with items manually. After implementing your custom loading logic, set the e.Handled parameter to true, so that DiagramControl does not load the previously selected document source.
CustomSaveDocument - The CustomSaveDocument event allows you to specify custom saving logic for your diagram. The event fires after the Save operation was initiated and selection was made in the Save dialog (if there was a dialog). The e.DocumentSource property in the event args specifies the default location (file name, stream, etc.) where the diagram will be saved. You can set the e.Handled parameter to true to cancel the standard saving logic and implement your custom one. For example, save the diagram to a stream using the SaveDocument method as demonstrated in the example or iterate through diagram items manually and read required information.

GridView - How to open the leftmost tab with invalid editors (PageControl is placed in the GridView's EditForm template)

$
0
0

This example is devoted to the scenario when there is a PageControl with Data Editors in the Edit Form template of the GridView extension and we need to validate the editors. In this scenario, it is necessary to use the approach illustrated in this example to activate the first tab with the invalid editors.

How to implement a custom object serializer

$
0
0

The following example shows how to implement a custom serializer.

Custom serializers are required when data source field values are custom objects (not numeric or string values). In this example, the data source contains a Sales Person field whose values are Employee objects, exposing the FirstName, LastName and Age properties. The Employee class implements the IComparable interface, and overrides the GetHashCode, Equals and ToString methods (required to display and handle custom objects).

The custom serializer is represented by the CustomObjectConverter class, which implements the ICustomObjectConverter interface. The ToString and FromString methods are implemented to serialize and deserialize the Employee objects, respectively. A CustomObjectConverter class instance is assigned to the PivotGridOptionsData.CustomObjectConverter property. It is used for serializing Sales Person field values when pivot grid data is saved to a stream and restored back by an end-user via clicking the Save and Load buttons respectively.


OBSOLETE - CheckComboBox filtering in the Auto Filter Row

$
0
0

UPDATED #2:

Please note that starting with version v13.1, ASPxGridView provides the column's FilterTemplate that allows using ASPxGridLookup as a multi-select AutoFilterRow editor. So, if you need to accomplish this task using the AutoFilterRow filter type (i.e., not the built-in multi-select Header Filter), consider using the approach illustrated in the E4521: ASPxGridView - How to change a default editor to ASPxGridLookup in FilterRow via FilterTemplate example instead.

UPDATED #1:

Please note that starting with version v12.1, ASPxGridView supports such a feature out-of-the-box. Please refer tot he Header Filter topic for details. For older versions, you can use the following solution.


This example demonstrates how to introduce a multi-select dropdown list, based upon column values, in the Auto Filter Row editor of a column.
 

1. There are two columns using an ASPxDropDownEdit editor with a checked ASPxListBox in its dropdown template.

The DropDownEditProperties object should be instantiated in the ASPxGridView.AutoFilterCellEditorCreate event handler as usual, but its adjustment should be performed in the ASPxGridView.AutoFilterCellEditorInitialize event handler.

2. When selecting/unselecting an item in the listbox, the corresponding element is added to the GridView's a filter condition with the GroupOperatorType.Or condition.

See Also:
Date range filtering in the Filter Row
ASPxGridView - Date auto filter
How to implement a CheckComboBox editor in the ASPxGridView

Question Comments

Added By: Satheesh Kumar R Karuppusamy at: 4/16/2014 6:41:28 AM    

how to use this along with linqservermodedatasource.?

dxDataGrid - Batch Editing - How to select several cells by holding the CTRL key to edit them simultaneously

$
0
0

This example illustrates how to allow end used to select more than one cell for editing by holding the CTRL key. Then, when the user changes the editor text, the same text will be entered to all selected cells. 

It is possible to implement this scenario by performing the following steps:

Create an array to store selected cells:

[JScript]
var editCells = [];

 Then, handle the onCellClick event to add the selected cell to the array when the Ctrl key is held or clear the array if it is not:

[JScript]
onCellClick: function(e){if(e.jQueryEvent.ctrlKey){ editCells.push(e.rowIndex + ":" + e.columnIndex);}elseif(editCells.length){ editCells = []; e.component.repaint();}},

 The onCellPrepared event is handled to change the style of the selected row: 

[JScript]
onCellPrepared: function(e){if(e.rowType === "data"&& $.inArray(e.rowIndex + ":" + e.columnIndex, editCells)>= 0){ e.cellElement.css("background-color", "lightblue");}},

 After that, handle the onEditorPreparing event to set the text value for all selected cells when a user edits the last cell:

[JScript]
onEditorPreparing: function(e){var grid = e.component;if(e.parentType === "dataRow"){var oldOnValueChanged = e.editorOptions.onValueChanged; e.editorOptions.onValueChanged = function(e){ oldOnValueChanged.apply(this, arguments);for(var i = 0; i < editCells.length; i++){var rowIndex = Number(editCells[i].split(":")[0]);var columnIndex = Number(editCells[i].split(":")[1]); grid.cellValue(rowIndex, columnIndex, e.value);}}}},

 To reset the selection when the Save or Cancel button is clicked, use the onContentReady event:

[JScript]
onContentReady: function(e){ e.element.find(".dx-datagrid-save-button").click(function(e){if(editCells.length) editCells = [];}); e.element.find(".dx-datagrid-cancel-button ").click(function(e){if(editCells.length) editCells = [];});}

Grid - How to Custom Paint Sort Glyphs in Column Headers

$
0
0
This example shows how to custom paint sort glyphs in column headers with the CustomDrawColumnHeader event.

How to convert group filter to get list of visible value if excluded filter type is set

$
0
0
This example demonstrates how to get a list of included values by comparing excluded values with all available values requested using the PivotGridGroup.GetUniqueValues methods. 

GridView - How to enable a responsive layout to integrate GridView into a Bootstrap-enabled application with responsive design

$
0
0
We use the Visual Studio Project Template to generate an application with responsive design. After that, we integrate the GridView extension into this application. Note that this extension provides responsive and adaptive layouts to accommodate to different devices' screens, but they are not enabled by default. Please review the following demos illustrating how to enable this functionality in a grid:

GridView - Responsive Layout
GridView - Adaptive Layout

Note:
Our Template Gallery also has the "Responsive Web Application" template.

See Also:
T250229 - How to make DevExpress web controls responsive
Viewing all 7205 articles
Browse latest View live


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