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

How to add Incremental Search into GridControl

$
0
0

This example demonstrates how to add Incremental Search into GridControl.

Our GridControl doesn't have Incremental Search. To provide this functionality, we subscribe to the GridControl's PreviewTextInput event. When PreviewTextInput is raised, we add the entered value to a searching string. Then, we iterate through all cells in a selected column. If a cell value starts with the searching string, we remember a row handle of this cell. To move to the previous or next row that starts with the searching string, we iterate through all previous or next cells of the current column and change the FocusedRowHandle value to a row handle of a found cell. To highlight the matching string of a cell, we cast InplaceBaseEdit to the InplaceBaseEdit interface and set the HighlightedText property to the searching string value.

Question Comments

Added By: Ankur Jain 7 at: 9/2/2016 6:45:51 AM    Hi,

I am trying to use the below implementation since my application is still using version 15.1.
However in the Grid_PreviewTextInput event handler the SearchString is always null.
Can you guide me where I am going wrong. 
it will be better if you can provide me with a sample project where incremental search is working using the behavior .

Thanks. Added By: Ivan (DevExpress Support) at: 9/2/2016 1:07:31 PM    

Hello,

I've created a separate ticket on your behalf (T422709). It has been placed in our processing queue and will be answered shortly.


WPF SpreadsheetControl API - Part 2

$
0
0

This example is the second part of the SpreadsheetControl API set of examples that demonstrates how to use the SpreadsheetControl API to programmatically manage spreadsheet documents, without the need for Microsoft Excel to be installed.

This sample introduces API properties and methods used to perform the following operations:

- Insert, delete and modify pictures
- Add a hyperlink to a picture
- Add custom functions to the spreadsheet
- Create and format a table

Starting from v2014 vol.1:

- Protect a workbook
- Protect a worksheet
- Apply user-specific permissions to a range in a protected worksheet
- Sort a range in descending and ascending orders
- Sort using a custom comparer
- Sort by multiple columns
- Simple search
- Search with options
- Export to HTML

Starting from v2014 vol.2:

- Group and outline data
- Insert subtotals
- Filter the data by a list of values
- Apply a number filter
- Apply a dynamic filter
- Sort the filtered data
- Specify the built-in document properties
- Specify the custom document properties

See also:
WPF SpreadsheetControl API - Part 1

WPF SpreadsheetControl API - Part 1

$
0
0

This example demonstrates how to use the SpreadsheetControl API to programmatically manage spreadsheet documents, without the need for Microsoft Excel to be installed.
Double-click the action name in the Navigation Bar to run the code that illustrates the API functionality. The results are shown in the SpreadsheetControl and saved to the SavedDocument.xlsx file in the Document subfolder of the working folder.

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

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

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

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

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

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

- Export the workbook to PDF

- Print the workbook


See also:
WPF SpreadsheetControl API - Part 2

How to enable in-place editing in the WinForms tree List View (TreeListEditor)

$
0
0

This example shows how to implement a custom ViewController that gets access to the TreeList control and makes it editable according to the XtraTreeList documentation:
    WinForms Controls > Controls > Tree List > Feature Center > Data Editing
    TreeListOptionsBehavior.Editable Property
    TreeList.ShowingEditor Event
    TreeList.CellValueChanged Event

Take special note that special handling is required for the correct operation of editors for reference properties (e.g., a lookup filtering functionality requires obtaining the currently selected record).
This is not a complete solution and you will need to modify and test this example code further in other scenarios according to your business requirements. For instance, if you require supporting ConditionalAppearance rules, consider using the code from the Q479878 ticket. If you require supporting member-level security permissions, consider extending this example by analogy with the DevExpress.ExpressApp.Win.SystemModule.GridListEditorMemberLevelSecurityController class for GridListEditor.

 

See also:

How to enable in-place editing in the ASP.NET tree List View (ASPxTreeListEditor)
Tree List Editors - How to edit data directly in the tree view (inplace / inline modifications)

Question Comments

Added By: Kerry Busby at: 6/21/2012 10:17:49 PM    

Are there any plans on ever incorporating this into the 'official' code base of XAF. The solution below previously could be manipulated with another controller to support EditorStateRule attributes and disable specific property editors however not that the EditorState module has been removed in DXPerience 2012 this is not possible or at least a LOT more difficult with the new Appearance module. There are a number of posts requesting this previously but currently it appears as if TreeLists with inplaced editing will never be 'officially' supported.

Added By: Willem de Vries at: 12/7/2012 3:11:17 AM    

+1 for Kerry!
DX, do not hesitate to upgrade Xpand gems to the XAF code base.
Willem

Added By: David Perfors at: 3/22/2013 6:17:49 AM    

A nice addition to this example is support for ImmediatePostDataAttribute:
[code lang="cs"]
void treeList_CellValueChanging(object sender, CellValueChangedEventArgs e)
        {
            if (ImmediatePostData(e))
            {
                SetValue(e);
            }
        }

        private void treeList_CellValueChanged(object sender, CellValueChangedEventArgs e)
        {
            if (!ImmediatePostData(e))
            {
                SetValue(e);
            }
        }

        private void SetValue(CellValueChangedEventArgs e)
        {
            object newValue = e.Value;
            if (e.Value is IXPSimpleObject)
                newValue = ObjectSpace.GetObject(e.Value);
            object focusedObject = _treeList.FocusedObject;
            if (focusedObject != null)
            {
                IMemberInfo focusedColumnMemberInfo = ObjectSpace.TypesInfo.FindTypeInfo(focusedObject.GetType()).FindMember(e.Column.FieldName);
                if (focusedColumnMemberInfo != null)
                    focusedColumnMemberInfo.SetValue(focusedObject, Convert.ChangeType(newValue, focusedColumnMemberInfo.MemberType));
            }
        }

        private bool ImmediatePostData(CellValueChangedEventArgs e)
        {
            if (_treeList.FocusedObject != null)
            {
                IMemberInfo focusedColumnMemberInfo = ObjectSpace.TypesInfo.FindTypeInfo(_treeList.FocusedObject.GetType()).FindMember(e.Column.FieldName);
                return focusedColumnMemberInfo.FindAttribute<DevExpress.Persistent.Base.ImmediatePostDataAttribute>() != null;
            }
            return false;
        }
[/code]

How to prompt when the user is about to exit a WinForms application

$
0
0

Scenario
A confirmation message appears when the main application window is being closed by a user to avoid accidental closure of the whole application and losing all opened screens:


Implementation
To use this solution in your project, simply copy the ...\WinSolution.Module.Win\PromptClosingLastMainWindowController.xx file into your WinForms module project.

GridView - How to export filtered data with Reports when using the BindToLINQ method with large data

$
0
0

At present our MVCxGridView export mechanism has some limitations: it is impossible to export a lot of filtered data, because the mechanism requests all data from a database and then filters it. Thus, a request can be fulfilled, and the 'System.OutOfMemoryException' exception occurs. As a solution, request filtered data yourself and export it using the XtraReports Suite. This example demonstrates how you can do this using LINQ-to-SQL.

To pass the FilterExpression to a Controller's Action, obtain and save it to GridView CustomJSProperties in CustomJSProperties:


[C#]
settings.CustomJSProperties=(s,e)=>{ASPxGridViewgrid=(ASPxGridView)s;e.Properties["cpGridFilterExpression"]=grid.FilterExpression;};settings.CustomJSProperties=Sub(s,e)DimgridAsASPxGridView=DirectCast(s,ASPxGridView)e.Properties("cpGridFilterExpression")=grid.FilterExpressionEndSub

When a user clicks the Export data, take the filter expression from GridView CustomJSProperties and add it to the collection of jQuery selector parameters.

[JavaScript]
function OnClick(s, e){var actionParams = $("form").attr("action").split("?filterString="); actionParams[1] = gvDataBindingToLinq.cpGridFilterExpression; $("form").attr("action", actionParams.join("?filterString="));}

The XtraReport class instance that's used in this Code Example is added as described in the Lesson 1 - Create a Static Report in ASP.NET MVC tutorial. The report controls are bound to data using the Embedded Fields (Mail Merge) feature.

You can learn more about approaches used in this example in the following resources:

How to: Create a Table Report
How to create a web based report at runtime
How to convert the CriteriaOperator to a lambda expression, so, the latter expression can be used in the IQueriable source

GridView Extension - Provide the capability to export large LINQ data
Walkthrough: Installing the AdventureWorks Database

Question Comments

Added By: Kevin Turpin 1 at: 2/10/2016 11:50:47 AM    OK, i absolutely love that i can do this, nicely done.Added By: John John Smith at: 3/23/2016 9:39:34 AM    There really isn't any difference between binding to an XtraReport just to export, and using a datatable is there?  The code in the home controller looks almost identical.

It doesn't matter how I filter my data, if it goes above the .Net 2gb limit then it throw the out of memory exception error.Added By: Vladimir (DevExpress Support) at: 3/23/2016 12:59:31 PM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T359906: The out of memory exception occurs when GridVIew data in being exported. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

How to provide ASPxReportDesigner with the SqlDataSource, ObjectDataSource, EFDataSource and ExcelDataSource at runtime

$
0
0
The main idea of this Code Example is to demonstrate how to create the aforementioned types of the data source components at runtime and add them to the list of the data sources available in the Web Report Designer.
Question Comments

Added By: Liu TzuYi at: 7/28/2015 2:30:12 AM    

Thanks, but I want use Microsoft SqlDataSource not Devexpress..DataAccess.Sql.DataSource
or use Microsoft SqlDataAdapter to create Dataset DataTable and assign it to ASPxReportDesigner !

So, Can you help more once  ?

Added By: Dmitry Tok (DevExpress Support) at: 7/28/2015 9:17:18 AM    Hello Liu,

Let's continue discussing this issue in the Can XtraReport bind multiple DataSource ? thread.
Thanks,
Dmitry

How to programmatically generate ObjectDataSource and map object data source constructor parameters to report parameters


How to filter the popup data source of a standalone LookUpEdit based on a value of another standalone LookUpEdit (using the CascadingOwner property)

$
0
0
This example demonstrates the use of the CascadingOwner property to perform automatic filtration of a LookUpEdit control's popup data source based on the value of another LookUpEdit control.
Note that the CascadingOwner property is supported only for standalone lookup editors.

To learn how to filter popup data sources of in-place lookup editors, see How to filter a second LookUp column based on a first LookUp column's value.

See Also:

How to create cascading lookup editors
Question Comments

Added By: Andrey Kushnarev at: 9/5/2016 8:36:43 AM    It works nice when you select second value by opening popup.
BUT if you try select second value by mouse wheel - OOPS..... :D
you have got all possible values - it is not good at all
Added By: Nadezhda (DevExpress Support) at: 9/5/2016 11:21:12 AM    Hello Andrey,

I have tried to reproduce the behavior, but my attempts were unsuccessful. I have attached a video to illustrate it: http://screencast.com/t/KEJL5F2l.
 Please see the video and clarify if we missed anything that can reproduce the issue.

Also, would you please create a video to illustrate how it works on your side? 

I look forward to your response.

ASPxSpreadsheet - How to save and load documents from a database

$
0
0

UPDATED:

This code example demonstrates how to save and restore ASPxSpreadsheet documents from a database using a Binary column.
Starting with version 15.1, we recommend using the ASPxSpreadsheet.Open method to load a document and call the ASPxSpreadsheet.SaveCopy method to save changes.

In version 15.2, it is also possible to handle the ASPxSpreadsheet.Saving event to save a document by clicking the ribbon's built-in Save button.


For Older Versions:
Use ISpreadsheetComponent.LoadDocument to load a document and ISpreadsheetComponent.SaveDocument - to save it.

See Also:
MVC Version:

T190813: Spreadsheet - How to save and load documents from a database

OBSOLETE - How to upload files from the EditForm

$
0
0

This example is now OBSOLETE.
It was prepared for older DXperience builds (v7.3).

At present, we recommend using the solutions illustrated in the following examples:
E2933: Inserting of a new row in ASPxGridView with the image preview enabled
E95: Image Upload in ASPxGridView

OBSOLETE:
Use an UploadPanel to enable file uploading inside the EditForm of the ASPxGridView. A full postback is currently required to use the FileUpload component. You can still use the FileUpload by instructing the UpdatePanel to do a postback for this control. The ASPxGridView will still use callbacks. To Enable: Put a FileUpload component inside of the UpdatePanel. Put the UpdatePanel inside the EditItemTemplate. Set a Trigger for the UpdatePanel to do a FullPostBack when uploading a file. Now handle the file on the server-side as you need.

Question Comments

Added By: Matej Mihalik at: 8/14/2013 5:17:59 AM    

it not work for me... function UploadBtn_Click doesnt found ID FileUpload1 and Label1...why?

Added By: Mike (DevExpress Support) at: 8/14/2013 5:37:28 AM    

Please create a new ticket in our Support Center and describe the issue you have encountered in greater detail.
A sample project that illustrates the issue would be helpful.

Added By: Daniel Kaminski at: 10/23/2014 10:04:39 AM    

This is a great example but it would be a lot more useful if it showed how to actually save the file to the database. Any chances of adding that, even if it is commented out?

Thanks,
Daniel

Added By: Luke (DevExpress) at: 10/23/2014 12:18:24 PM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T164891: E19 example - How to actually save the file to the database. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

How to implement conditional formatting for cells

$
0
0

The following sample demonstrates how to change the appearance of grid cells in a certain column based upon some condition. For example, in this tutorial you can see that the background color of cells in the second column is gradually changed based on the value in this cell.

Question Comments

Added By: Zhigeng Fan at: 12/7/2015 6:58:02 AM    

how to do conditional formatting on all cells regardless of columns? I want to gray all cells where the value is null

Added By: Alexander Rus (DevExpress Support) at: 12/7/2015 9:58:20 AM    

Hello Zhigeng,
To process your recent post more efficiently, I created a separate ticket on your behalf: T321646: How to apply the same formatting rule to all columns

Thanks,
Alexander

How to implement conditional formatting for rows

$
0
0

The following sample demonstrates how to change the appearance of grid rows based on a condition.

Question Comments

Added By: Fahad at: 7/9/2013 3:50:45 AM    

Is there an easy way to Style each cell ? Or we have to use DataTemplate ?

Added By: Mary Roy at: 6/5/2014 1:46:45 PM    

Your sample does not work

Added By: Michael Ch (DevExpress Support) at: 6/6/2014 12:42:08 AM    Hello Mary,

Thank you for your remark. I have corrected this sample. Please review it.

Thanks,
Michael

TokenEdit - How to implement reordering tokens via Drag&Drop

$
0
0
This example demonstrates how to implement the Drag and Drop functionality for reordering tokens.
Question Comments

Added By: Elena (DevExpress Support) at: 1/28/2016 1:21:16 AM    

Also, review the improvement of this example created by our customer.

How to: Apply format conditions to grid rows and/or cells at runtime

$
0
0

This example illustrates how to apply format conditions to grid rows and/or cells at runtime.


How to: Show the color determined by conditional formatting when a row is focused

$
0
0
This example demonstrates how to show the color determined by a conditional formatting when a row is focused.

How to export MVCxPivotGrid and the bound ChartControl to the same print document

$
0
0

This example illustrates how to export MVCxPivotGrid and the bound ChartControl to the same print document. 

Question Comments

Added By: James Badenhorst 1 at: 9/6/2016 3:55:38 AM    Hi Devexpress,
The default grid and chart opens with a filter of 3 products.
If you add a product (or 2) to the  pivot grid filter, the change is reflected on the bound chart, but the exported chart retains the original filter of 3 products.
Regards
James
Added By: Maxim (DevExpress Support) at: 9/6/2016 5:15:09 AM    

Hello,

I've created a separate ticket on your behalf (T423774: How to export a pivot and a chart to the same print document with a current filter applied). It has been placed in our processing queue and will be answered shortly.

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

$
0
0

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 make a grid column fit all the available space

$
0
0

This example demonstrates how to make a specific grid column fit all the available space when AutoWidth is disabled. Starting with version 16.1, this task can be accomplished by setting the required column's Width to *.

How to show a specific View for some users

$
0
0

Scenario:

This example demonstrates how to show a custom View against a role of the currently logged user. Custom Views were created and customized through the Model Editor for each role separately. For more convenience, custom Views have a name of a role in the Id attribute. For instance: Contact_ListView_Administrators, Contact_DetailView_Administrators, Contact_ListView_Users, Contact_DetailView_Users, etc. You may consider a specific naming convention, for example, to add a role name to the end of the view name.
Use User and Admin user names with empty password to login in to application.


Implementation details:

There is CustomizeViewAgainstRoleMainWindowController that tracks View showing using the XafApplication.ViewCreating event and replaces the default View's Id with a custom Id found in the Application model by the role name. 

Alternatively, you can handle the XafApplication.UserDifferencesLoaded event and patch the ViewID of required navigation items under the NavigationItems node as well as the DefaultListView/DefaultDetailView attributes of the BOModel | Class nodes.

Question Comments

Added By: Serkan Dede 1 at: 1/14/2016 10:27:35 AM    

Hi,

I got error in Application_ViewShowing method on line :
e.View.SetModel(modelView);

Error Message:
Cannot change property 'DefaultSorting' when the XPCollection is not in design or initialization mode.

Any idea to resolve this issue?

Added By: Dennis (DevExpress Support) at: 1/15/2016 2:02:00 AM    

Hello Serkan,

To process your recent post more efficiently, I created a separate ticket on your behalf: T334575: The "Cannot change property 'DefaultSorting' when the XPCollection is not in design or initialization mode" error occurs when calling e.View.SetModel(modelView);. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Joel Sanches at: 4/20/2016 11:27:52 AM    This is marked as obsolete. What would be the present recommendation to handle the same scenario in XAF?Added By: Alexey (DevExpress Support) at: 4/21/2016 9:25:16 AM    

Hello Joel ,
I've created a separate ticket on your behalf (T370594: E274 in 15.2). It has been placed in our processing queue and will be answered shortly.

Viewing all 7205 articles
Browse latest View live


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