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

How to generate a sequential and user-friendly identifier field within a business class

$
0
0

Scenario

Orders, articles or other business entities often require that you have user-friendly Id or Code fields that end-users can memorize and use during phone conversations. They are usually sequential, but some gaps can be allowed as well (e.g., when an order is deleted). Refer to this StackOverFlow thread for more information on this common scenario, and a possible implementation.

Steps to implement

1. Add a new business class to your platform-agnostic module, and  call the static DevExpress.Persistent.BaseImpl.DistributedIdGeneratorHelper.Generate method from the AfterConstruction, OnSaving or other appropriate places within your persistent class or even Controller as shown in the Solution2.Module\BusinessObjects\Order.xx file. Depending on your business requirements, you can implement a readonly persistent or editable property where the generated value will be stored as well as check various conditions before generating the next sequence (e.g., string.IsNullOrEmpty(currentSequenceProperty) - to avoid double assignments, Session.IsNewObject(this) - to check whether the object is new, !(Session is NestedUnitOfWork) - to check whether the object is being saved to the database and not to the parent session, security system checks as per this blog post, etc.)

2. Build your platform-agnostic project and double-click on the Solution2.Module\Module.xx file to invoke the Module Designer;

3. Refer to the Exported Types section within the designer and expand the Referenced Assemblies | DevExpress.Persistent.BaseImpl node;

4. Select and press the space bar on the OidGenerator and ServerPrefix nodes to include these types into the business model of your module:

IMPORTANT NOTES
1. The DistributedIdGeneratorHelper class demonstrated in this solution creates the IDGeneratorTable and ServerPrefix tables to store the information about the last sequential number of a type.
Although this particular solution is simpler to implement and maintain (as it uses built-in XAF classes) than the How to generate and assign a sequential number for a business object within a database transaction, while being a part of a successful saving process (XAF) example, it is pretty safe and should also work in the most typical business scenarios (except for the middle-tier Application Server scenario, because the Session.DataLayer property is not initialized in this case).

2. You can find functional EasyTest scripts for this scenario in the Solution2.Module\FunctionalTests\E4904.ets file.

Question Comments

Added By: Gareth- at: 10/2/2013 5:58:17 AM    

Thanks, works perfectly - I've seeded the ID by manually changing the [Oid] in the IDGeneratorTable, do I need to worry about the [OptimisicLockField] or will this update automatically?

Added By: Dennis (DevExpress Support) at: 10/2/2013 7:10:50 AM    

@Gareth: No, you do not need to care about the OptimisticLockField.

Added By: MohammedFarooq at: 12/2/2013 1:07:31 AM    

Hi,

The code is really helpful but it increments the value of code even if the record is deleted! How can we stop the code to increase its value when a record is deleted?

Added By: MohammedFarooq at: 12/2/2013 1:25:16 AM    

I manage to figure out the solution. I have just added the IsDeleted checking and it worked like a charm!!!

    Protected Overrides Sub OnSaving()
        If (Not IsDeleted) Then
             Me.codeCore = String.Format("N{0:D6}", DistributedIdGeneratorHelper.Generate(Me.Session.DataLayer, Me.GetType().FullName, String.Empty))
        End If
        MyBase.OnSaving()
    End Sub

Added By: Dennis (DevExpress Support) at: 12/2/2013 1:26:50 AM    

@Mohammed: Yes, your solution is correct. I will consider updating this example accordingly. Thanks for your input in this regard.

Added By: rushdan . at: 11/6/2014 12:02:48 AM    

Hallo

I do not understand about explanation. What I know is, after I run the application, then save the data , it will execute Code number automatically.

Is it this example to show how to execute auto increase number ? Thanks

Added By: Dennis (DevExpress Support) at: 11/6/2014 2:00:43 AM    

@Rushdan: With the current implementation, the generation code is executed when the persistent object is being saved (OnSaving). I do not quite understand your last question. The functionality implemented in this example is well-detailed in the description and it can also be seen from simple code.

Added By: Andrew Bingham 2 at: 2/5/2015 12:40:25 AM    

"override its AfterConstruction method, as shown in the Solution2.Module\BusinessObjects\DomainObject1.xx file"

1. I cannot find the DomainObject1 file in the sample
2. The only BusinessObject is Order.cs which does not have an AfterConstruction method
3. What code need to go in AfterConstruction method?
4. What are the advantages / disadvantages compared to E2829?

Added By: Dennis (DevExpress Support) at: 2/5/2015 12:47:04 AM    @Andrew: Thanks for your feedback.
1-3. I've corrected this misprint in the description. 
3. This particular solution is simpler to implement than E2829.Added By: Vishwas Mokashi at: 4/21/2015 8:52:32 AM    

Is there any provision so that we can restart the Sequence Number after say an Year is completed?. Also, any way to give the start number for the sequence?.

Added By: Dennis (DevExpress Support) at: 4/21/2015 8:57:35 AM    

@Vishwas: Sure, you can do this. Technically, the information about the last sequence number is stored in the Oid column of the IDGeneratorTable table with the help of the OidGenerator persistent class. You can modify this data using either ADO.NET or XPO means.

Added By: Vishwas Mokashi at: 4/21/2015 9:02:11 AM    

Ok thanks Dennis...will try

Added By: MohammedFarooq at: 10/14/2015 2:37:53 AM    

Dear Dennis,

I have applied this logic in my project which also has validation enabled. Now the issue is, if the validation of the document fails while saving the new number is generated. And when the user saves the document again then a new number is generated as well.

Added By: Dennis (DevExpress Support) at: 10/14/2015 2:58:59 AM    @Mohammed: The original example has the if(string.IsNullOrEmpty(Code))  check that prevents multiple generations. Have you applied this code in your project? If this does not help, submit a separate ticket and attach your problematic sample so we can assist you further.

How to export GridView data to different text formats

$
0
0

This example is standalone implementation of the online Grid View - Exporting Data demo.
It illustrates how to export the GridView 's content to several rich text formats via the ExportTo*** methods.

This example is an illustration of the KA18639: How to export GridView rows and keep end-user modifications (such as sorting, grouping, filtering, selection) KB Article. Refer to the Article for an explanation.

Please note the following key moments:
- The GridView Extension should be defined via a separate PartialView without any additional tags (see the Using Callbacks help topic for more information);
- The GridView's PartialView should be wrapped within a form in order to apply the client layout state (sorting, filtering, etc.);
- An export trigger should submit this form to the corresponding Controller Action (i.e., make a POST request);
- The GridViewSettings (especially the Name property) should be the same in PartialView and Controller;
- The datasouce/Model should be the same in PartialView and Controller.

Question Comments

Added By: Nurhak Kaya at: 9/4/2012 7:58:55 AM    

Really good! Thanks a lot!

Added By: Steven Jansick at: 7/11/2014 11:44:57 AM    

Does this work when binding with BindToCustomData?

I have verified that all of the Conditions have been met but when I export, it is not maintaining the Grouping Order.  Do you have any recommendations?

Added By: Mike (DevExpress Support) at: 7/14/2014 12:05:58 AM    

Hello,

To process your recent post more efficiently, we copied it to a separate ticket created on your behalf: T128968: GridView - Export Data when using BindToCustomData method.
This ticket is currently in our processing queue. We will post to it as soon as we have any updates.

How to export only selected GridView rows to different output text formats

$
0
0

This example is an illustration of the KA18639: How to export GridView rows and keep end-user modifications (such as sorting, grouping, filtering, selection) KB Article. Refer to the Article for an explanation.

Question Comments

Added By: Kitty at: 11/20/2013 6:23:08 AM    

Good Morning

I'm having the same issues with windows grid, please share the link if you have any sample code addressing "How to export GridView rows and keep end-user modifications (such as sorting, grouping, filtering, selection) " on windows GRid control

Added By: vkr at: 4/6/2014 8:19:37 PM    

I need the "Run Online" component to work to finish my task.. plz help..

Added By: vkr at: 4/6/2014 9:04:43 PM    

Hello, this is fantastic, I need the exact sample as the attached one here.. please check , the attached sample is not working..

ON "Run Online" here on this page, the export to xls/pdf or any other format is not exporting data.. plz check once..

and I need this sample for version 13.2

Added By: Mike (DevExpress Support) at: 4/6/2014 11:47:21 PM    

You can download the example's source code via the "Downloads" section or play this solution online via the "Run Online" button.
If you need further assistance/clarification, please create a new ticket in our Support Center and share your current progress with us. We will do our best to put you on the right track.

Added By: vkr at: 4/7/2014 12:11:59 AM    

Your 'Run Online' is not working. and Example runner is giving some error. I am having an issue like this:

All rows are exported and not the ones only I filtered.. Your Run Online code is also not exporting.. so if you can fix that, I can try to get the code from there..

Export ASPxPivotGrid with additional text captions in header or footer

$
0
0

This example illustrates how to export the ASPxPivotGrid with additional text captions in a header area to the same print document. It is also possible to add a report footer below the pivot grid in the same way.

Question Comments

Added By: Brian Banaszynski at: 6/4/2012 1:43:37 PM    

When we add a header/footer in this fashion, their is an extra page getting added in the end. Is there anyway to avoid that? Also when the document is opened its prompting us to save which is unwarranted. Can that be avoided as well?

Let me know.

Added By: softboy99 at: 10/25/2012 4:48:55 AM    

If we want to CreatePageForEachLink function, how can we add the text captions?

Added By: Daniel Kaminski at: 4/2/2013 7:56:02 AM    

Run Online link seems to be broken.... could this be fix?

Added By: Daniel Kaminski at: 4/2/2013 8:08:30 AM    

Is there a way to add header and footers when using ExportPdfToResponse or ExportCsvToResponse

Added By: Daniel Kaminski at: 10/21/2013 3:00:42 PM    

Is it possible to do this or something similar using the WinForms pivotgrid? I would like to add some headererr notes when the pivot grid is exported to excel

Added By: Alex (DevExpress Support) at: 10/14/2015 12:18:21 PM    Hi Daniel,

We apologize for missing your comments in this thread.
A note for everybody looking for a solution related to the PIvotGridControl (WinForms): it is possible to use the approach shown in the How to print a grid with an additional header and footer? example to add custom header/footer information when printing the PivotGridControl data.

How to Generate persistent metadata for an arbitrary data table

ASPxGridLookup - How to implement the multiple selection DropDownWindow scenario

$
0
0

This example demonstrates how to use the ASPxGridLookup to select multiple values from a dropdown grid containing lookup items. The ASPxGridLookup is bound with the custom DataItem defined within the "LookUpDataItem" type (contains row field).

The embedded ASPxGridView component is pre-customized as the ASPxListBox:

- The ASPxGridView's Header is hidden;

- The ASPxGridView's Pager is used for splitting DataItems within multiple pages to improve the client-side performance.


The embedded ASPxGridView's sever-side "CustomJSProperties" event is attached by handling the ASPxGridLookup's Init event. To get a reference to the embedded ASPxGridView, use the ASPxGridLookup.GridView property.

The embedded ASPxGridView's client-side "SelectionChanged" event is attached by handling the ASPxGridLookup's Init event, via the ASPxGridLookup.GridView.ClientSideEvents.SelectionChanged property.


UPDATED:

Starting with version v2014 vol 1 (v14.1), the "Select All" functionality is available out of the box:
S173621: ASPxGridView - Add the built-in SelectAll CheckBox for Command Column

Simply set the GridViewCommandColumn.SelectAllCheckboxMode property to GridViewSelectAllCheckBoxMode.AllPages to activate it. Please refer to the ASP.NET: GridView Select All Rows Updated blog post and the Select All Rows demo for more information.

OBSOLETE:

For the "Select All" functionality, instructions from the ASPxGridView - How to implement SelectRows and SelectAllRowsOnPage CheckBox features KB Article is used.

For the "partial selection" functionality, newly implemented ASPxCheckBox rendering (ASP.NET Check Box - New Render State For Multiple Controls (available now in v2011.1)) is used.

Question Comments

Added By: Neha Wahi at: 10/15/2015 1:52:54 AM    

I cannot use grid lookup column as that column has comma separated values, and I want to show disticnt values for that column as a lookup. Also I want a type ahead functionality.

Added By: Nastya (DevExpress Support) at: 10/15/2015 4:49:44 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T300697: ASPxGridLookup - How to show distinct values. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

How to bind ASPxGridView to a collection of objects with nested lists

$
0
0

This example demonstrates how to display a collection of objects with nested lists using ASPxGridView. Note that this approach doesn't support data shaping operations (sorting, grouping, filtering) out of the box. It is required to implement these operations manually if you need them.

Scaffolding Wizards - How to show validation errors when IDataErrorInfo is used

$
0
0

This example demonstrates how to show validation errors when IDataErrorInfo is used. For more information, refer to the corresponding help topic.

You can encounter the following exception:

A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll

Additional information: 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: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)

This error is caused because the EntityFramework uses the missing LocalDB component.

To fix the issue, locate the App.config file within your application and open it. Change the defaultConnectionFactory in the following manner:

[XAML]
<defaultConnectionFactorytype="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
Question Comments

Added By: Marc Esteve at: 10/15/2015 8:06:43 AM    

I implement IDataErrorInfo and validation is performed correctly. However, error Icons are not displayed beside DevExpress editors within my Winforms user control.
Why?

Added By: Alexander S (DevExpress Support) at: 10/15/2015 10:16:34 AM    

Hi Marc,

To process your recent post more efficiently, I created a separate ticket on your behalf: T300893: Editors don't show validation errors from the IDataErrorInfo when located in a WinForms user control. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.


How to implement the search functionality in a GridControl

$
0
0

This example demonstrates how to implement searching against grid columns - an end-user types in text in a search bar and all cells containing the entered string are highlighted on the fly. A complete description is available in the How to: Implement the Search Functionality topic.

How to customize a GridControl theme

$
0
0

This example demonstrates how to customize a theme used to paint a GridControl. A complete description is available in the How to: Customize Themes topic.

How to filter a second LookUp column based on a first LookUp column's value

$
0
0

This is an example for the How to filter a second LookUp column based on a first LookUp column's value Knowledge Base article. Please refer to the article for the explanation.

Question Comments

Added By: Lexikos at: 3/22/2013 1:44:56 AM    

this example is not complete at all!!!!

Added By: Alex Xie(GM) at: 5/13/2013 2:30:50 AM    

this sample has a bug, if USA has a city code 202, and Russia has a city code 202, then there will be a problem, please try to use the following code lines in function filldataset

            dataSet11.Countries.AddCountriesRow("USA", "1", 1);
            dataSet11.Countries.AddCountriesRow("Germany", "49", 2);
            dataSet11.Countries.AddCountriesRow("France", "33", 3);
            dataSet11.Countries.AddCountriesRow("Great Britain", "44", 4);
            dataSet11.Countries.AddCountriesRow("Italy", "39", 5);
            dataSet11.Countries.AddCountriesRow("Russia", "7", 6);

            dataSet11.Cities.AddCitiesRow("Washington", "202", "1", 1);
            dataSet11.Cities.AddCitiesRow("Los Angeles", "213", "1", 2);
            dataSet11.Cities.AddCitiesRow("San Francisco", "415", "1", 3);
            dataSet11.Cities.AddCitiesRow("New-York", "718", "1", 4);
            dataSet11.Cities.AddCitiesRow("Berlin", "30", "49", 5);
            dataSet11.Cities.AddCitiesRow("Bonn", "228", "49", 6);
            dataSet11.Cities.AddCitiesRow("Munhen", "89", "49", 7);
            dataSet11.Cities.AddCitiesRow("Paris", "1", "33", 8);
            dataSet11.Cities.AddCitiesRow("Lion", "19", "33", 9);
            dataSet11.Cities.AddCitiesRow("London", "1274", "44", 10);
            dataSet11.Cities.AddCitiesRow("Glasgo", "141", "44", 11);
            dataSet11.Cities.AddCitiesRow("Rome", "6", "39", 12);
            dataSet11.Cities.AddCitiesRow("Milan", "2", "39", 13);
            dataSet11.Cities.AddCitiesRow("Moscow", "202", "7", 14);

            dataSet11.Phones.AddPhonesRow(1, "39", "6", "xxx");
            dataSet11.Phones.AddPhonesRow(2, "33", "19", "yyy");
            dataSet11.Phones.AddPhonesRow(3, "1", "202", "zzz");

then run the sample, then select Russia, then select Moscow , and tab out, you'll see the values changed to Washington.

Added By: Svetlana (DevExpress Support) at: 10/16/2015 1:22:57 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T301102: E898 does not work correctly when identical codes are used. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

How to use the TextFormatString property for multi-column ASPxComboBox

$
0
0

This example demonstrates how to use the TextFormatString property for a multi-column ASPxCombobox. The text of the selected ASPxComboBox item displayed within the input box is formatted by the TextFormatString property. This property value is specified according to the selected ASPxRadioButtonList item.

Question Comments

Added By: K R at: 5/7/2014 4:57:16 AM    

This does not work. Try typing Jones and you can only ever see John Doe. Your multicolumn comboboxes simply do not work with TextFormatString.

Added By: Alessandro (DevExpress Support) at: 5/7/2014 7:29:29 AM    Hi,

The behavior of the EnableIncrementalFiltering option, which is already obsolete, equals the newly implemented IncrementalFilteringMode.StartsWith option (see ASPxComboBox - EnableIncrementalFiltering is obsolete). You can use the IncrementalFilteringMode.Contains option instead in newer ASPxComboBox versions. I have modified this example accordingly. I hope this information helps. 

P.S.: If you have any additional questions, please create a separate ticket in our Support Center. Thank you for your time and cooperation in advance.

Added By: Dogan YILMAZ at: 10/16/2015 4:59:26 AM    

comboBoxProperties.TextFormatString = "{0} {1} {2}".Split(' ')[1].ToString();

How to merge cells horizontally in GridView

$
0
0

This example demonstrates how to merge cells located in the same row. The main idea is to paint merged cell manually.
You can find a helper class in this example, which can be easily connected to your existing GridView.

Question Comments

Added By: John Nyari at: 9/16/2013 9:57:18 AM    

Hi - all leads for horizontal merging seem to lead here. I have integrated it and found it works very well. However I seem to get a crash if the cells its merging are cells that have already been merged vertically. I am running v2012 12.2.8. Thanks

Added By: Maxim (DevExpress Support) at: 9/16/2013 11:32:16 PM    

Hello John,

I have opened a separate issue on your behalf:

Application crash when using an approach from the E2472 example and merging cells horizontally

Please refer to this report for further correspondence on this item.

Added By: Chris Janssen 1 at: 12/18/2013 12:17:48 PM    

It also crashes if you merge cells cells that have different types of data in them (merge a cell with an integer and a cell with a string)

Added By: Chris Janssen 1 at: 12/18/2013 12:30:39 PM    

After more testing It seems to crash because of an infinite loop.

        If _view.GetRowCellValue(rowHandle, column) isNot value Then
            _view.SetRowCellValue(rowHandle, column, value)
        End If

The above code doesn't work when comparing integers, it always says they're different, so it keeps changing the value and getting called infinitely. When changed to

        If _view.GetRowCellValue(rowHandle, column) <> value Then
            _view.SetRowCellValue(rowHandle, column, value)
        End If

it works.

Added By: HansG at: 1/2/2014 9:30:55 AM    

I think there is an error in addMergedCell:
The desired value of the cell is not put in the mergedCell list. This is, because the AddMergedCell with the integers as parameters does not use the AddMergedCell variant with "value".
To fix this add parameter "value" to the call of AddMergedCell in MyCellMergeHelpler.cs.
This will also fix the view of the strings, that where defined in Form1().

Alternativly don ́t use .absoluteIndex and just use the columns.

Added By: Dan Nordin at: 10/6/2014 7:12:40 PM    

Hi, thanks for this example.  The only problem I have with it is when you convert your grid over OptionsView.AutoColumnWidth = false and then scroll over so that one of the merged columns starts to disappear off the left side of the grid, it ends up covering up the Indicator column.  Likewise if you scroll so the columns start to disappear off the right they end up covering about 1 pixel of the frame of the grid on the right side of the scrollbar (the far side of it).  If this could be remedied in the example that would be a huge help to me because I need to implement this in a big grid with lots of scrolling.  Thanks.

Added By: Demetrius (DevExpress Support) at: 10/7/2014 2:49:26 AM    

Hi Dan,

I need to clarify some details to process your recent post more efficiently. I have created a separate ticket on your behalf: E2472 - Merged cells disappear while scrolling. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Philipp G at: 6/10/2015 2:31:14 AM    

Hi, is there a way to also always display an Editor in the merged cell? (We would like to always display a RepositoryItemButtonEdit in one of the merged cells)

Added By: André (DevExpress Support) at: 6/10/2015 4:52:22 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T253679: How to display RepositoryItemButtonEdit in one of the merged cells. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Jim Hansen 1 at: 10/15/2015 11:32:33 AM    

I found I had to make these three changes to get it working correctly:

In the MyGridPainter.DrawMergedCell()  add a check for a null ViewInfo before getting the bounds
if (gridCellInfo1.ViewInfo == null)//// this sometimes has a null ViewInfo for some reason.
               return;

The AddMergedCell overload that took ints for the columns was missing the call to set the value.
       public void AddMergedCell(int rowHandle, int col1, int col2, object value)
       {
           MyMergedCell cell = AddMergedCell(rowHandle, _view.Columns[col1], _view.Columns[col2]);
           SafeSetMergedCellValue(cell, value);
       }

The SafeSetCellValue needed to unbox the values before doing the compare.
       public void SafeSetCellValue(int rowHandle, GridColumn column, object value)
       {
           if (_view.GetRowCellValue(rowHandle, column).ToString() != value.ToString())
               _view.SetRowCellValue(rowHandle, column, value);
       }

Added By: Nadezhda (DevExpress Support) at: 10/16/2015 6:01:40 AM    I am happy to hear that you have found the solution. Feel free to contact us in case of further difficulties.

How to completely hide the dock panel's caption?

$
0
0

By setting the DockManager.DockingOptions.ShowCaptionOnMouseHover property it's possible to set whether the dock panel's caption is shown only when the mouse pointer hovers over the panel's top or all the time.

This example demonstrates how to prevent the dock panel's caption from being shown for an individual dock panel all the time.

Question Comments

Added By: Leopold Cudzik at: 6/17/2014 5:27:08 AM    

Hello, thank you for this solution, however I have a question. When I undock customDockPanel2 - the one whose caption is being hidden and afterwards I hide its caption,  the panel looks quite ugly as there is no top border. So the floating panel has borders from 3 sides, however from the top, there is nothing.  Is there a workaround to paint to the top the same border as from the other 3 sides,when the caption bar is hidden?

Thanks

Added By: Olga (DevExpress Support) at: 6/17/2014 6:37:53 AM    Hello Leopold,

In order not to mix several questions in one thread, I've created a separate ticket on your behalf: Example E1940 - How to paint the top border in the same manner as other ones. Please refer to it.

Added By: Hakan Lindestaf 1 at: 10/16/2015 4:47:32 PM    

This workaround worked reasonably well, but I would like this supported natively by DevExpress (and also include the fix for the top border). Can you please add this as a feature request?

ASPxSpellChecker - Getting Started

$
0
0

This tutorial demonstrates how to use the ASPxSpellChecker component to create a simple web application with the spell-checker functionality. It can be useful for you in solving this task if you are a first-time user of ASPxSpellChecker.

This example demonstrates how to check spelling in one specified control located within a control container. To do it, you should set the ASPxSpellChecker.CheckedElementID property to the ID of the control to be checked, handle the ASPxSpellChecker.CheckedElementResolve event to specify the control to be checked, call the ASPxClientSpellChecker.Check method in the button's client-side Click event handler. Note: you can check all text-aware controls located within a control container by using the ASPxClientSpellChecker.CheckElementsInContainer method.
Note: You can replicate the same project by performing steps from the following tutorial: ASPxSpellChecker - Getting Started.


OBSOLETE - Inserting a new row in ASPxGridView with the image preview enabled

$
0
0

UPDATED:

Starting with version v2015 vol 1 (v15.1), this functionality is available out of the box. Simply set the GridViewDataBinaryImageColumn.PropertiesBinaryImage.EditingSettings.Enabled property to True to activate it. Please refer to the ASP.NET Data Grid - Binary Image Editor (Coming soon in v15.1) blog post and the Binary Image Column Editing demo for more information.

If you have version v15.1+ available, consider using the built-in functionality instead of the approach detailed below.

This example shows how to use ASPxUploadControl on the ASPxGridView's Edit Form to preview an image before performing data update.

See Also:
OBSOLETE - Image Upload in ASPxGridView
How to bind the ASPxBinaryImage to a field which contains image data stored as OLE object

Question Comments

Added By: David Black 2 at: 2/27/2015 9:14:41 AM    

So do i have to create a custom edit form just to add an an image? Not sure why the software doesn't generate the upload code for you.

I am familiar with WinForms but the ASP model is new to me I tried to follow the example below but received an error on 'ConvertOleObjectToByteArray' I am sure there is something I need to include.

Any help in beginners terms for customizing would be greatly appreciated.

Added By: Alessandro (DevExpress Support) at: 2/27/2015 10:22:46 AM    Hi,

I see that you already posted this question to the T213772: ASPxGridView - How to change image in the Edit Form ticket. It is currently in our processing queue. We will handle it soon. Please bear with us.Added By: Rosario Terranova at: 6/10/2015 1:24:41 AM    

An question for you.
The metods callbackPanel_Callback and ucImage_FileUploadComplete  as are declared and what they do on the server (VB)?

Added By: Rosario Terranova at: 6/10/2015 1:47:52 AM    

An question for you.
The metods callbackPanel_Callback and ucImage_FileUploadComplete  as are declared and what they do on the server  INSIDE(VB)?

Added By: Mike (DevExpress Support) at: 6/11/2015 4:37:53 AM    

Hello Rosario,

To process your recent post more efficiently, I created a separate ticket on your behalf: T254295: E2933 - How the ucImage_FileUploadComplete and callbackPanel_Callback events are used. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: jose pais 1 at: 10/19/2015 11:21:05 AM    

Do you have a code sample in vb.net with asp.net just with .PDF file?

Added By: Helen (DevExpress Support) at: 10/20/2015 1:03:29 AM    Hello Jose,

I see that you asked the same question in the T301975: ASPxGridView - How to use upload function in a when editing a row ticket. Please refer to it for further assistance. 

How to hide individual navigation items and groups for certain users

$
0
0

Scenario:


Our Security System allows hiding navigation items for certain users by setting the Type Permission's Navigate access. Since with this approach, the Navigate access can be granted only for a certain type, the following scenarios are not supported:

1. It is necessary to hide a DashboardView.
2. There are several navigation items for a certain type, and it is required to hide a part of them.
3. It is necessary to hide a navigation item that is not associated with a certain View (e.g., a navigation group).


This article demonstrates how to extend the security role class with the HiddenNavigationItems property allowing hiding navigation items by their ID.

Steps to implement:

1. Implement a custom permission type - NavigationItemPermission - that can be used to check access permissions for a certain navigation item by its ID.
2. Implement a custom permission request - NavigationItemPermissionRequest - that will be sent to check whether the current user has access to a certain navigation item.
3. Implement a custom permission request processor - NavigationItemPermissionRequestProcessor - that determines whether the current user has permissions for the received permission request.
4. Register the permission request processor in the application by handling the SecurityStrategy.CustomizeRequestProcessors event in the Program.cs and Global.asax.cs files.
5. Implement a custom role with the HiddenNavigationItems property. Override the role's GetPermissionsCore method to create NavigationPermission instances based on the value of the HiddenNavigationItems property.
6. Specify the custom role in the Security System's RoleType property in the Application Designer, as described in the How to: Implement Custom Security Objects (Users, Roles, Operation Permissions) topic.
7. Implement a ShowNavigationItemController's descendant - CustomShowNavigationItemController - and override its SynchItemWithSecurity method to deactivate navigation items prohibited by the CustomSecurityRole.HiddenNavigationItems property.

After implementing these steps in your project, you will be able to assign a role with the HiddenNavigationItems property to the required users to restrict their access to certain navigation items.

Question Comments

Added By: Maurice Picton at: 6/10/2014 7:52:32 AM    

Can someone post the HideNavigationItemsExample that is mentioned below in the code?
I'm having trouble implementing this solution.

Added By: Maurice Picton at: 6/10/2014 8:00:46 AM    

In the steps to implement, none of the entities you describe are in any of the documentation and I can't locate them in visual studio.

Added By: Anatol (DevExpress Support) at: 6/10/2014 8:07:44 AM    These classes are implemented in this example. You can see their code below, under the comments. To download the complete example, use the Downloads - Example link at the right edge of this page.Added By: Randy Jean at: 2/13/2015 11:15:42 AM    

Is there a way to make this be least restriction has precedence.  For instance, if I have a users role that hides navigation items and a direct role that does not hide, can the director role take precedence over the user role somehow?

Added By: Randy Jean at: 2/13/2015 11:33:21 AM    

think I may have come up with a way to make this work.  If I add a wildcard * to my HiddenNavigationItem then modify the IsGranted like so:

       public override bool IsGranted(NavigationItemPermissionRequest permissionRequest) {
           foreach (NavigationItemPermission permission in permissions.GetPermissions<NavigationItemPermission>()) {
               if (permission.HiddenNavigationItem == permissionRequest.NavigationItem) {
                   return false;
               } else if (permission.HiddenNavigationItem.Replace("*","") == permissionRequest.NavigationItem) {
                   return true;
               }
           }
           return true;
       }

This seems to do what I want.  So I can have user with the restrictions but then override in Director with the wildcard character like this: AddressGroup*, Person_Varied*

Do you see any issues with this?

Added By: Anatol (DevExpress Support) at: 2/16/2015 6:16:18 AM    

I am not sure that this approach will work in all cases, since the GetPermissions method returns permissions from all user roles, and with your implementation the first permission always wins. So, it is better to set a boolean variable based on the permission's HiddenNavigationItem property and return this value after processing all NavigationItemPermission permissions.

How to automatically send a report via e-mail

$
0
0

The following example demonstrates how to automatically send a report via e-mail. To do this, a report should first be exported into one of the available formats. In this example, a report is exported to PDF, since this format provides the best output quality (the PDF result is as close to a report's print result as possible).

Question Comments

Added By: MohammedFarooq at: 10/20/2015 1:11:44 PM    

Hi,
I am getting the following error when the button is clicked. For your information, i am executing this logic in XAF viewcontroller SimpleAction button execute event

Error sending a report.
System.Exception: Null object cannot be converted to a value type. ---> System.Exception: Null object cannot be converted to a value type. ---> System.InvalidCastException: Null object cannot be converted to a value type.
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType)
at DevExpress.XtraReports.UI.XRSubreport.ApplyParameterBindings()
at DevExpress.XtraReports.UI.XRSubreport.OnBeforePrint(PrintEventArgs e)
at DevExpress.XtraReports.UI.XRControl.GetPrintableBrick(XRWriteInfo writeInfo)
at DevExpress.XtraReports.UI.XRControl.WriteContentTo(XRWriteInfo writeInfo)
at DevExpress.XtraReports.UI.Band.GenerateContent(DocumentBand docBand, Int32 rowIndex, Boolean fireBeforePrint)
at DevExpress.XtraReports.UI.Band.GenerateContentAndDecompose(DocumentBand docBand, Int32 rowIndex, Boolean fireBeforePrint)
at DevExpress.XtraReports.UI.Band.CreateDocumentBand(Int32 rowIndex, RootDocumentBand rootDocBand, PageBuildInfo pageBuildInfo)
at DevExpress.XtraReports.UI.DetailBand.CreateDocumentBand(Int32 rowIndex, Int32 rowCount, RootDocumentBand rootDocBand, PageBuildInfo pageBuildInfo)
at DevExpress.XtraReports.Native.Printing.DetailWriterBase.WriteDetailCore(PageBuildInfo pageBuildInfo)
at DevExpress.XtraReports.Native.Printing.DetailWriterBase.Write(DocumentBand rootBand, PageBuildInfo pageBuildInfo)
at DevExpress.XtraReports.Native.Printing.DocumentBuilder.GetBand(DocumentBand rootBand, PageBuildInfo pageBuildInfo)
at DevExpress.XtraPrinting.Native.DocumentBand.GetBand(PageBuildInfo pageBuildInfo)
at DevExpress.XtraPrinting.Native.PageHeaderFooterRowBuilderBase.CanProcessDetail(DocumentBand rootBand, PageBuildInfo pageBuildInfo)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBands(DocumentBand rootBand, RectangleF bounds, ProcessBandsDelegate process)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillReportDetails(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageHeaderFooterRowBuilderBase.FillReportDetailsAndFooter(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPage(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageRecursive(DocumentBand rootBand, DocumentBand docBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageHeaderFooterRowBuilderBase.FillPageRecursive(DocumentBand rootBand, DocumentBand docBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBandCore(DocumentBand rootBand, RectangleF bounds, RectangleF newBounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBand(DocumentBand rootBand, RectangleF bounds, RectangleF newBounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBands(DocumentBand rootBand, RectangleF bounds, ProcessBandsDelegate process)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillReportDetails(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageHeaderFooterRowBuilderBase.FillReportDetailsAndFooter(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPage(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageRecursive(DocumentBand rootBand, DocumentBand docBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageHeaderFooterRowBuilderBase.FillPageRecursive(DocumentBand rootBand, DocumentBand docBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBandCore(DocumentBand rootBand, RectangleF bounds, RectangleF newBounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBand(DocumentBand rootBand, RectangleF bounds, RectangleF newBounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBands(DocumentBand rootBand, RectangleF bounds, ProcessBandsDelegate process)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillReportDetails(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageHeaderFooterRowBuilderBase.FillReportDetailsAndFooter(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPage(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageRecursive(DocumentBand rootBand, DocumentBand docBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageHeaderFooterRowBuilderBase.FillPageRecursive(DocumentBand rootBand, DocumentBand docBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBandCore(DocumentBand rootBand, RectangleF bounds, RectangleF newBounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBand(DocumentBand rootBand, RectangleF bounds, RectangleF newBounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBands(DocumentBand rootBand, RectangleF bounds, ProcessBandsDelegate process)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillReportDetails(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageHeaderFooterRowBuilderBase.FillReportDetailsAndFooter(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPage(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageRecursive(DocumentBand rootBand, DocumentBand docBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageHeaderFooterRowBuilderBase.FillPageRecursive(DocumentBand rootBand, DocumentBand docBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBandCore(DocumentBand rootBand, RectangleF bounds, RectangleF newBounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBand(DocumentBand rootBand, RectangleF bounds, RectangleF newBounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBands(DocumentBand rootBand, RectangleF bounds, ProcessBandsDelegate process)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillReportDetails(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageHeaderFooterRowBuilderBase.FillReportDetailsAndFooter(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPage(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageBuildEngine.Build()
at DevExpress.XtraPrinting.Native.PageBuildEngine.BuildPages(DocumentBand rootBand, Boolean clearGroupingInfo)
--- End of inner exception stack trace ---
at DevExpress.XtraPrinting.PrintingSystemBase.OnCreateDocumentException(ExceptionEventArgs args)
at DevExpress.XtraPrinting.Native.PageBuildEngine.RaiseCreateDocumentException(Exception exception)
at DevExpress.XtraPrinting.Native.PageBuildEngine.BuildPages(DocumentBand rootBand, Boolean clearGroupingInfo)
at DevExpress.XtraPrinting.Native.DocumentHelper.BuildPagesCore()
at DevExpress.XtraPrinting.Native.DocumentHelper.BuildPages()
at DevExpress.XtraPrinting.Native.PrintingDocument.BuildPages()
at DevExpress.XtraPrinting.Native.PrintingDocument.End(Boolean buildPagesInBackground)
at DevExpress.XtraPrinting.PrintingSystemBase.End(Boolean buildPagesInBackground)
at DevExpress.XtraReports.UI.XtraReport.CreateDocumentCore(PrintingSystemBase ps, Single progressRange, Boolean buildPagesInBackground)
at DevExpress.XtraReports.UI.XtraReport.CreateDocument(Single progressRange, Boolean buildPagesInBackground, Boolean suppressClearDataContext)
at DevExpress.XtraReports.UI.XtraReport.TryCreateDocument(Single progressRange, Boolean buildPagesInBackground, Boolean suppressClearDataContext)
--- End of inner exception stack trace ---
at DevExpress.XtraPrinting.PrintingSystemBase.OnCreateDocumentException(ExceptionEventArgs args)
at DevExpress.XtraReports.UI.XtraReport.TryCreateDocument(Single progressRange, Boolean buildPagesInBackground, Boolean suppressClearDataContext)
at DevExpress.XtraReports.UI.XtraReport.CreateIfEmpty(Single progressRange, Boolean buildPagesInBackground)
at DevExpress.XtraReports.UI.XtraReport.ExportToPdf(Stream stream, PdfExportOptions options)
at DevExpress.XtraReports.UI.XtraReport.ExportToPdf(Stream stream)
at Solution6.Module.vcPayroll.SimpleAction1_Execute(Object sender, SimpleActionExecuteEventArgs e) in E:\My Docs\Projects\Solution6\Code\Solution6.Module\BusinessObjects\10 Payroll\Payroll Run\vcPayroll.vb:line 179

Added By: MohammedFarooq at: 10/20/2015 1:12:27 PM    

The error happens at this line

report.ExportToPdf(mem)

Added By: Ingvar (DevExpress Support) at: 10/21/2015 1:28:10 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T302655: NullReferenceException when trying to apply solution described in E16. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

How to implement CRUD operations using XtraGrid and OData

$
0
0

This example demonstrates how to bind the GridControl to the BindingSource and populate it with data retrieved from the WCF Data Services.

Entities and data context classes generated by Visual Studio when you add a service reference to WCF Data Service lacks automatic handling modifications performed to entities such as changing property values, creating new objects or deleting objects from the collection. A programmer must handle all these changes manually to ensure that all changes will be sent to the service. One can create extensions over generated classes and custom collections that can automatically post all changes to the data context, but this example demonstrates a simpler approach that can be used in small applications where it does not require using complex solutions for such tasks.

This example demonstrates how to use GridView events and the embedded navigator to properly update the Data Service.

Each time the user makes modifications in cells and commits a modified row, the GridView raises the RowUpdated event. This is the optimal moment to notify the data context that an entity was modified:

[C#]
voidOnRowUpdated(objectsender,DevExpress.XtraGrid.Views.Base.RowObjectEventArgse){MyEntities.UpdateObject(e.Row);}
[VB.NET]
Sub OnRowUpdated(ByVal sender AsObject, ByVal e As DevExpress.XtraGrid.Views.Base.RowObjectEventArgs) Handles MyGridView.RowUpdated MyEntities.UpdateObject(e.Row)EndSub

The EmbeddedNavigator.ButtonClick event of the GridControl's embedded navigator allows you to handle the CREATE and DELETE operations.

[C#]
usingDevExpress.XtraEditors;voidOnEmbeddedNavigatorButtonClick(objectsender,NavigatorButtonClickEventArgse){switch(e.Button.ButtonType){caseNavigatorButtonType.Append:e.Handled=true;MyEntities.AddObject("MyTableName",MyBindingSource.AddNew());break;caseNavigatorButtonType.Remove:MyEntities.DeleteObject(MyGridView.GetFocusedRow());break;}}

[VB.NET]
Imports DevExpress.XtraEditorsSub OnEmbeddedNavigatorButtonClick(ByVal sender AsObject, ByVal e As NavigatorButtonClickEventArgs)SelectCase e.Button.ButtonTypeCase NavigatorButtonType.Append e.Handled = True MyEntities.AddObject("MyTableName", MyBindingSource.AddNew())Case NavigatorButtonType.Remove MyEntities.DeleteObject(MyGridView.GetFocusedRow())EndSelectEndSub

See also:
Updating the Data Service (WCF Data Services)
How to implement CRUD operations using DXGrid and WCF Data Services

How to implement CRUD operations using XtraGrid and WCF Server Mode

Viewing all 7205 articles
Browse latest View live


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