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

List - How to create a list with multiple columns

$
0
0
Use CSS to split dxList into multiple columns.

See also:
How to inspect CSS rules
Question Comments

Added By: Liz Summers at: 2/8/2017 12:02:16 PM    This makes nice columns but it does not reformat to smaller screen/mobile like the solution in http://codepen.io/anon/pen/QdaOXK

The codepen link was referred to me by Nikolai in a support ticket re creating a dxlist with multiple columns.  We've implemented that solution.

I looked at this to see if something new and different... 

How to add commands to the context menu to save a range in different formats

$
0
0

This example illustrates how you can create a set of commands which descend from a common base class and add them to context menu of the RichEditControl. Every command implements a certain method used to get selected range in specific format.
To add a menu item, the RichEditControl.PopupMenuShowing event is handled. A new RichEditMenuItem instance is created and associated with a command. The command provides Content and Glyph for displaying the menu item.
All commands descend from the SaveDocumentAsCommand command and implement the ICommand interface. The ExecuteCore method is overridden and invokes the custom Save As... dialog. The GetSelectedContents method is implemented in command descendants to get a byte array of selected range in a specified format.

Since Silverlight application has quite limited file system access, the project is run in out-of-browser mode with elevated permissions. It enables the application to save data on the local host in special folders (e.g. My Documents). If the application is run without elevated permissions, only streams obtained via the SaveFileDialog are available, and the custom UriProvider will throw security exception. The command's UpdateUIStatemethod is overridden to check for elevated permissions and disable the HTML export command if this criteria is not met. Likewise, the base UpdateUIState method disables a command if the selection length is zero so there is nothing to export.

To get selected range in a required format, the commands use the GetOpenXmlBytes, GetRtfText and GetHtmlText methods. The latter method gives rise to two commands - one that works without an UriProvider and another that uses a custom provider to save images. A command without an UriProvider sets the EmbedImages option to true so images are base64 encoded and embedded into the HTML page.

How to validate ObjectDataSource in the Spreadsheet mail merge template

How to bind a web report to a collection of custom objects at design time

$
0
0

This example illustrates how to bind a report to lists for web projects at design time. To do this you need to extract your reports together with the corresponding classes representing your business objects into a separate assembly. Then, you can easily perform all necessary design-time binding using the BindingSource component (by specifying the required object type as its DataSource).

This approach differs from how this is done under the Windows Forms platforms in that you cannot assign your object to the BindingSource.DataSource property at design time. Instead, you should perform the binding right within the InitializeComponent method.

Question Comments

Added By: CodeGal at: 1/21/2014 7:21:17 PM    

So what are the design time bindings for controls set to in the report?

Added By: Olena at: 3/5/2014 5:03:22 PM    

Hi Support Team,
I've just downloaded Example and I see error in the XtraReport1.cs tab saying

"Could not find type 'Reports.Data'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU. "

Unfortunately there is no ability to attach print screen.
What can I do to fix it?

Thanks!

Added By: ghsPt at: 4/7/2014 10:21:33 AM    

Hello!

I have a dataset with several objects.
If I want a list of several different objects with only one datasource, how can I do that?

Added By: Matt_Olson at: 7/20/2014 3:57:26 PM    

Missing design time objects in xtrareport1.cs

Added By: Andrew L (DevExpress Support) at: 7/21/2014 7:21:26 AM    Hello Matt,

To process your recent post more efficiently, I created a separate ticket on your behalf: T131788: E1936 - Missing design time objects . This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Matt_Olson at: 7/21/2014 8:03:37 AM    

Sorry, I see that the missing source code is in the Example Runner download.  It is only missing from the web viewable portion (such as definition for InitializeComponent()) which is in XtraReport1.designer.cs I'm guessing which isn't in the web viewable version.

Added By: Andrew L (DevExpress Support) at: 7/21/2014 10:02:49 PM    Hi Matt,

I am happy to hear that the problem has been resolved. Thank you for letting us know of your progress. Please feel free to contact us if you have any further difficulties. We will be happy to assist youAdded By: Lisa Bencic at: 8/27/2014 1:52:19 PM    

I run this example in my 14.1 environment and it works fine.  If I swap out the Report Viewer for the ASPxDocumentViewer, I get the old "Object reference not set...."
Is there an example that uses ASPxDocumentViewer?  
I saw in this link: http://www.devexpress.com/Support/Center/Question/Details/T119505
That it's 'NOT' good to store the Xtrareport in a session variable, that it is too complex.  Is it more complex with the Doc Viewer instead of Report Viewer?

Added By: Dmitry Tok (DevExpress Support) at: 8/27/2014 10:33:45 PM    

Hello Lisa,

To process your recent post more efficiently, I created a separate ticket on your behalf: T144862: How to set up binding for a web report using a collection of custom objects as a data source at design time. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.
Thanks

Added By: Aakash Bashyal Bashyal at: 8/14/2015 8:54:02 PM    

Please provide the Example in MVC for the same purpose.

Added By: Jannet (DevExpress Support) at: 8/17/2015 2:19:04 AM    Hello Aakash,
Thank you for your request. I have put it in our TODO list. 

In fact, the reporting tools are platform-agnostic. At that point, I suggest that you check the current solution and additionally, take a look at the following example created under the ASP.NET MVC platform:
How to create a master-detail report bound to an ORM (Entity Framework) model in MVC applications

Feel free to contact us in case of further difficulty.

Thanks,
Jannet

How to iterate through the auto-created series to perform custom calculations

$
0
0

This example demonstrates how to iterate through the series points created via SeriesTemplate to perform any additional calculations.

For this, you should handle a specific BoundDataChanged event of the chart control, where you can obtain these series.

Keeping a checked filter item displayed when records are removed from the data source

$
0
0

The following example demonstrates how to keep a checked filter item displayed when all records with the corresponding field value are removed from the data source.
In this example, the CustomFilterPopupItems event is handled to ensure whether all filter values are represented in the filter items list.
Initially, the filter of the Product Name field is set to include only the Alice Mutton and Aniseed Syrup products into the report. An end-user can emulate removing all records Alice Mutton from the data source. In this instance, the 'Alice Mutton' filter item would normally be hidden from the filter drop-down. Handling the CustomFilterPopupItems event allows adding the 'Alice Mutton' filter item into the drop-down explicitly.


ASP.NET Core Dashboard Control - How to specify a default dashboard state in code

$
0
0

The sample illustrates how to specify a dashboard state (such as master filter or parameter values) in code and how to apply this state when loading a dashboard for the first time. In this example, the DashboardState object defined in the Controller holds the required dashboard state. The MVC approach is used to pass the specified dashboard state to the View's DashboardBuilder.InitialDashboardState property and use this state on loading a dashboard.

How to create a master-detail GridView with paging and sorting using Custom Data Binding

$
0
0

This sample demonstrates how to manually provide data for two GridView extensions that are used in a master-detail relationship. In this implementation, only sorting and paging operations of the grids are handled in the corresponding Action methods.

To learn more on the GridView's custom data binding feature, please refer to the Custom Data Binding - Overview help topic.

Note that this sample provides a universal implementation approach. It can be easily adopted and used for every custom data source object if it implements the IQueryable interface.

The common logic of each grid's custom binding implementation is similar to the implementation demonstrated by the E4394 code sample. The difference is that in this sample the master grid's detail row template is defined by using another (detail) GridView extension. Each detail grid instance is provided with information on the corresponding master row's key field value. This value is passed to a detail grid's Action methods (as a parameter) and to the grid's Partial View (as a ViewData object).

In short, this sample's implementation logic is as follows:


In both grid Partial Views (see MasterGridViewPartial.cshtml and DetailGridViewPartial.cshtml in Views > Home), a grid's CustomBindingRouteValuesCollection property is used to define handling actions for sorting and paging operations; the CallbackRouteValues property defines the action to handle all other (standard) grid callbacks. In the master grid's Partial View, the SetDetailRowTemplateContent method delegate is implemented to define detail row content and provide it with the master row's key field value - the value of the "CustomerID" column. In the detail grid's Partial View, the received corresponding master row key field value (the value of the "CustomerID" column) is passed to the specified actions.

In the Controller (Controller > HomeController.cs), the specified Action methods are implemented for both grids to update a specific grid view model object (GridViewModel that maintains a grid's state) with information of the performed operation (if required). Then, a grid view model's ProcessCustomBinding method is called to delegate a binding implementation to specific model-layer methods pointed by the method's certain parameters.

At the Model layer (see MasterCustomBindingModel.cs and DetailCustomBindingModel.cs in Models), two specified delegates are implemented for each grid to populate the corresponding grid view model with the required data. Generally, in the provided implementation of model-level binding delegates, you just need to modify a single code line in each model file to point to your particular model object:

[C#]
(MasterCustomBindingModel.cs)staticIQueryableModel{get{returnNorthwindDataProvider.GetCustomers();}}
[C#]
(DetailCustomBindingModel.cs)staticIQueryableModel{get{returnNorthwindDataProvider.GetInvoices();}}

Finally, the resulting grid view model object is passed from the Controller to a particular grid's Partial View as a Model. For a detail grid, the master row key value is also passed to the Partial View as a ViewData object. In the Partial View, each grid binds to the Model via the BindToCustomData method.

Note that when implementing the grid's custom data binding, the DevExpressEditorsBinder must be used instead of the default model binder to correctly transfer values from DevExpress editors back to the corresponding data model fields. In this code example, the DevExpressEditorsBinder is assigned to the ModelBinders.Binders.DefaultBinder property within the Global.asax file, thus overriding the default model binder.

See Also:
How to implement a simple custom binding scenario for GridView


How to convert Word-like documents to PDF on a web server

$
0
0

This example demonstrates how to implement a Word-to-PDF converter with a web interface. A server-side RichEditDocumentServer component loads a file in a Word-like document format and converts it to PDF. The resulting file is sent to the client.

How to implement a simple custom binding scenario for GridView

$
0
0

This sample demonstrates how to implement a simple custom binding scenario for the GridView extension by handling only sorting and paging operations in the corresponding Action methods.

To learn more on the GridView's custom data binding feature, please refer to the Custom Data Binding - Overview help topic.


Note that this sample provides a universal implementation approach - it can be easily adopted and used for every data source object that implements the IQueryable interface.

 

In short, the logic of this custom binding implementation is as follows:


In the GridView's Partial View (Views > Home > GridViewPartial.cshtml), the grid's CustomBindingRouteValuesCollection property is used to define handling actions for sorting and paging operations; the CallbackRouteValues property defines the action to handle all other (standard) grid callbacks.


In the Controller (Controller > HomeController.cs), the specified Action methods are implemented to update a specific grid view model object (GridViewModel that maintains the grid state) with the information of the performed operation (if required). Then, the grid view model's ProcessCustomBinding method is called to delegate a binding implementation to specific model-layer methods pointed by the method's certain parameters.


At the Model layer (Models > CustomBindingModel.cs), the two specified delegates are implemented to populate the grid view mode with the required data. Generally, in the provided implementation of model-level binding delegates, you just need to modify a single code line to point to your particular model object:

[C#]
staticIQueryableModel{get{returnNorthwindDataProvider.GetCustomers();}}

Finally, the resulting grid view model object is passed from the Controller to the grid's Partial View as a Model. In the Partial View, the grid binds to the Model via the BindToCustomData method.

Note that when implementing the grid's custom data binding, the DevExpressEditorsBinder must be used instead of the default model binder to correctly transfer values from DevExpress editors back to the corresponding data model fields. In this code example, the DevExpressEditorsBinder is assigned to the ModelBinders.Binders.DefaultBinder property within the Global.asax file, thus overriding the default model binder.

 

See Also:
E4398: How to create a master-detail GridView with paging and sorting using Custom Data Binding

Question Comments

Added By: Prasanth Sasidharan 2 at: 2/2/2017 1:46:55 PM    Could you please show how to implement server side filtering alsoAdded By: Helen (DevExpress Support) at: 2/3/2017 12:15:30 AM    Hello Prasanth,

You can find an example of the Custom Binding scenario with filtering in this demo: Custom Data Binding (Advanced).

How to filter by null and empty cell values using Filter Bar when FilterMode is DisplayText

$
0
0

When a header filter is used for a column and its FilterMode is set to “DisplayText”, the predefined “(Blanks)” criterion returns rows with values equal to null or empty, whereas in a grid’s Filter Bar the “Is blank” condition will not return anything. 

This can be described by the fact that in the former case, the resultant CriteriaOperator will be built as “IsNullOrEmpty”, while in the latter case it will be “IsNull”. In order to make Filter Bar work in the same way, it’s possible to parse its filter expression and replace IsNull operator with the required IsNullOrEmpty

This example uses a parsing technique demonstrated in E3396: How to delete all criteria corresponding to a particular field from CriteriaOperator. In this case, the CriteriaHelper class was slightly modified so that the UnaryOperator of type IsNull is replaced by the FunctionOperator of type IsNullOrEmpty.

The modified filter expression is applied on a grid’s callback.

How to save ASPxSplitter's client-side layout after every end-user modification

How to edit ASPxTreeList's row by clicking an external button and delete rows with a custom confirmation popup

How to use ASPxGridLookup two-way bound to LinqServerModeDataSource in GridViewDataComboBoxColum

$
0
0

This example demonstrates how to utilize the GridViewDataComboBoxColumn that retrieves "lookup" values via the Dynamic List Population mode (in a browse ASPxGridView mode).

The ASPxGridLookup, which is defined within the column's EditItemTemplate, is used as the column's editor and bound with a separate LinqServerModeDataSource control via the two-way binding option. This approach is useful when ASPxGridLookup should be bound to a large data source.

To use the default ASPxComboBox editor (produced by the GridViewDataComboBoxColumn PropertiesComboBox), which operates in a "Dynamic List Population" mode, simply remove the column's EditItemTemplate (with the ASPxGridLookup control) definition.

See also:
Server Mode Overview

How to edit Nullable field with the ASPxGridView and ASPxImage in EditItemTemplate

$
0
0

Starting with version 2011.1:
I recommend that you use ASPxCheckBox instead of the demonstrated solution since the control supports the Undefined (Grayed) checked state, see ASP.NET Check Box - New Render State For Multiple Controls for details.


Prior version 2011.1:
The example demonstrates how to edit the Boolean field that allows writing "null" values (Nullable<Boolean>, Boolean?).
As the standard checkbox doesn't allow having three states (checked, unchecked and gray), the scenario can be implemented with the ASPxImage and three images. The images are taken from the default CSS sprite used by the ASPxEditors suite.


How to render DevExpress ASP.NET controls' resources outside the output-cached UserControl

$
0
0

This sample demonstrates how to use ASPxStyleSheetManager and ASPxScriptManager components to avoid a loss of scripts and style sheets of DevExpress ASP.NET controls placed within an output-cached UserControl after the page refresh.

If the UserControl cache is enabled, DevExpress ASP.NET control style sheet links and scripts are rendered on the initial page load only. Therefore, they are not appended to the page after reload.

Registering the required styles and scripts manually by ASPxStyleSheetManager and ASPxScriptManager components resolves the issue.

How to get selected file names if ASPxUploadControl operates in multi-file selection mode

$
0
0

This example demonstrates how to get a list of names of selected files if ASPxUploadControl operates in multi-file selection mode


Question Comments

Added By: Stuart Duncan at: 8/8/2013 3:14:05 AM    

This works, however it seems to remove any spaces in the filenames. Changing the pipe character to a question mark in the replace pattern seems to correct this.

Added By: David Hoffmann at: 9/18/2015 7:26:43 AM    

The problem is, that "," (comma) is allowed in filenames!

How to edit data in a DataTable using ASPxGridView at runtime when data is stored in ViewState

$
0
0

This example shows how to insert, edit and delete data in a data table by using ASPxGridView. The data table and the grid are created at runtime.
To be able to store data in ViewState, the ASPxGridView.EnableCallBacks property should be set to False. Refer to the K18387: The Concept of Callbacks article for additional details.

See Also:
KA18686: ASPxGridView - How to implement CRUD operations with a custom data source
T191009: How to insert, edit and delete data in a data table by using ASPxGridView at runtime when data is stored in Session
Editing an in-memory dataset

How to bind ASPxGridView created at runtime to different data sources

$
0
0

This example shows how to select and bind ASPxGridView to a data source at runtime. In design mode the page contains ASPxRadioButtonList and three data sources (SqlDataSource), not ASPxGridView. The grid will be added to the page at runtime.
Grid's data source is changed by clicking list items.
Note that the grid's view state is enabled and the grid will restore its columns after it has been appended to the page. Therefore we clean up grid columns just after that and before binding the data source.

See also
How to dynamically switch the grid's data source and recreate columns at runtime
How to bind ASPxGridView with manually created columns to different data sources at runtime. The grid is created in design mode.
How to bind ASPxGridView with autogenerated columns to different data sources at runtime. The grid is created at design mode

How to sort integer and string type values using the ASPxGridView CustomColumnSort event

$
0
0

This example shows how to sort columns with integer and string type values using the CustomColumnSort event of ASPxGridView. All numbers sort these strings, but if a string type value is numeric it is sorted as a number, rather than a string.

Viewing all 7205 articles
Browse latest View live


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