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

WinForms End-User Designer - How to customize the Chart Wizard

$
0
0
This example demonstrates how to implement a custom Chart Wizard in the End-User Report Designer. In this example, we replace the default wizard logo with a custom one. 
To achieve this, create a custom XRChart control (Creating Custom Controls) and provide a custom XRChartDesigner (How to customize the Chart Wizard) for this control.

See also:
How to: Register a Custom Control in the End-User Designer's Toolbox
How to provide display names for custom properties or a custom control
End-User Designer - How to customize the control's Smart Tag menu

WinForms End-User Designer - How to resize the Parameters panel

How to rotate a diagram to avoid segment shifting

$
0
0

If a series point value is changed, you may wish to keep an old start segment position. It is possible to use the PieSeries2D.Rotation property for this task. 

How to dynamically generate a report in a WPF application

$
0
0
This example illustrates the process of creating a report in code in a WPF application. 

The following steps are essential to create a report layout:

1. Create a report instance and bind it to data.

2. Add required bands to the report.

3. Add required controls to the created bands and provide data to them.

After the report layout is complete, you can generate the report document and display it in a Print Preview.

WPF End-User Report Designer - How to Implement a Report Storage

$
0
0
The following example demonstrates how to implement a report storage to persist report definitions in a database or in any other custom location. This may be useful when providing end-users with the capability to create and customize reports using XtraReports End-User Designer if it is necessary to have a common target for saving and sharing all reports. At present, the aforementioned functionality is accomplished through the DevExpress.Xpf.Reports.UserDesigner.IReportFileStorage interface. The interface provides the following methods:
       • ShowSaveAsDialog
       • ShowOpenDialog
       • Load
       • Save
       • GetErrorMessage
As we see, the interface methods are quite straightforward: the first two methods are intended to show a dialog to an end-user where he can select a report among the predefined reports, or otherwise, save it; when he does that, the Save or Load methods are invoked with the unique name of the selected report. That's where you should implement your custom save logic. If you're unfamiliar with this procedure, please refer to the original E2704 example, which provides additional information in this regard (the example illustrates the same technique but for WinForms EUD)
__________________________________________________________________________________________________________________________________________

[v15.2 History changes]
The IReportFileStorage interface has been changed to IReportStorage.
This new interface provides the following methods:

• bool CanCreateNew();

Indicates where or not it's possible to create a new tab with a blank report in the designer.
• bool CanOpen();

Indicates where or not the "Open" BarItem is enabled.
• XtraReport CreateNew();

Provides the capability to customize a new report template.
 • XtraReport CreateNewSubreport();

Provides the capability to customize a new subreport report template (i.e., a new report opened by double-clicking a given XRSubreport control)
• string GetErrorMessage(Exception exception);

Provides the capability to display an error message for any encountered exception (a general one or the exception message if you expect that the user can understand and react based on this information)

• string Open(IReportDesignerUI designer);

This method expects a unique ID of the report selected by an end-user via your own UI dialog.
• XtraReport Load(string reportID, IReportSerializer designerReportSerializer);

This method passes the report ID that has been selected in the previous step and expects the actual report instance to be loaded and returned. You may or may not use the IReportSerializer  facilities to save or load a given report from a stream.

 • string Save(string reportID, IReportProvider reportProvider, bool saveAs, string reportTitle, IReportDesignerUI designer);

This method is intended to save the currently edited reports. 
The methods parameters are:
reportID is the unique ID of the edited report (null if it's a new report with no ID specified)
reportProvider allows you to get the actual report instance being edited and optionally rename it (a new name will be updated in the designer as well)
saveAs indicates which particular BarItem has been pressed ("Save" or "Save As")
reportTitle represents the actual report title (XtraReport.DisplayName)
designer is the actual report designer instance (the DevExpress.Xpf.Reports.UserDesigner.ReportDesigner class). Again, it's up to you whether to use it or not
__________________________________________________________________________________________________________________________________________

NOTE:
The WPF Report EUD is still in the beta stage (v.15.2.5); thus, there can be some limitations which are impossible to overcome at this moment (for example, there is no way to fill the SubReport's ReportSource drop-down window with the list of available reports). Moreover, some detail implementation may be changed on its official release. If you're experiencing any issues with running this sample or have additional questions, please contact our Support Team directly for further assistance.

WPF End-User Report Designer - How to hide a property in the Properties window

$
0
0
This example demonstrates how to hide the "DataSource", "DataMember", and "DataAdapter" properties in the Properties window.

First, get the Property Grid from the visual tree. I completed this by using the LayoutTreeHelper class. Then, get a property definition instance from the PropertyGridControl.PropertyDefinitions collection and set PropertyDefinitionBase.Visibility to Collapsed to hide a property.
Here are some points regarding how to get a property from the PropertyGridControl.PropertyDefinitions collection. Some properties are determined by the PropertyDefinitionBase.Path property (for instance, the "DataSource" and "PrinterName" properties). To hide them, compare the PropertyDefinitionBase.Path property value with the string value (e.g. "DataSource") to get a property object from PropertyGridControl.PropertyDefinitions.
Other properties are determined by the type. To hide them, create a brand new PropertyDefinitionBase object (set up its Path as required) and add it to the PropertyGridControl.PropertyDefinitions.

WinForms: WinForms End-User Report Designer - How to hide a property in the Properties window

WPF End-User Report Designer - How to customize the Ribbon toolbar

$
0
0

This example demonstrates how add two custom items to the Ribbon toolbar of the Banded End-User Report Designer. These custom items allows you to manage the designer's side panel's and toolbox's visibility.


To customize the WPF Banded End-User Report Designer's Ribbon toolbar use it's RibbonTemplate: Get the original RibbonTemplate XAML code from our source files, add it to your application, customize it according to your requirements and assign it to the ReportDesigner.RibbonTemplate property.

In this example, I have added the RibbonPageGroup with two BarCheckItems to the Report Designer's RibbonTemplate and bound these items to the CustomizedRibbonCommands class properties. This class object (CustomRibbonCommands) is assigned to the MainWindow and realizes the side panel and toolbox showing/hiding logic:

[XAML]
<DataTemplatex:Key="CustomizedRibbonTemplate"><dxr:RibbonControl...><dxr:RibbonDefaultPageCategory><dxr:RibbonPageCaption="Report Designer"> ...<dxr:RibbonPageGroupCaption="View"><dxb:BarCheckItemContent="Toolbox"IsChecked="{Binding CustomRibbonCommands.IsToolboxVisible, RelativeSource={RelativeSource FindAncestor, AncestorType=local:MainWindow}}"LargeGlyph="{dx:DXImage Image=IDE_32x32.png}"Glyph="{dx:DXImage Image=IDE_16x16.png}"/><dxb:BarCheckItemContent="Side Panel"IsChecked="{Binding CustomRibbonCommands.IsSidePanelVisible, RelativeSource={RelativeSource FindAncestor, AncestorType=local:MainWindow}}"LargeGlyph="{dx:DXImage Image=Technology_32x32.png}"Glyph="{dx:DXImage Image=Technology_16x16.png}"/></dxr:RibbonPageGroup></dxr:RibbonPage></dxr:RibbonDefaultPageCategory> ...</dxr:RibbonControl></DataTemplate>

WPF End-User Report Designer - How to create a custom data source wizard


WPF End-User Report Designer - How to customize the popup menu of a report

Runtime table creation best practices (iterative approach)

$
0
0

This example demonstrates the differences in runtime table creation between the newest XtraReports version and its prior versions.

Please note that it is always required to call the XRTable.BeginInit and XRTable.EndInit methods if you modify XRTable.Rows and XRTableRow.Cells collections at runtime.

As for the height of a table, explicitly specify it only if cells' content is not expected to stretch the cells (e.g. this may happen when their CanGrow property is enabled).

See also:
How to convert an XtraGrid to an XtraReport at runtime

Question Comments

Added By: DXScorpion at: 10/14/2013 3:12:53 AM    

Your sample is too simple.
In case datasource has many columns and total width of columns greater than (Report.PageWidth - Report.Margins.Left - Report.Margins.Right) How can we show all of it on report?

Added By: Leon Zeng at: 9/19/2014 5:55:49 AM    

The example works fine.  However,
(1) It's better to use gridColumn's width, caption and fieldName
(2) When dataset has more than 1 table, the cells show empty. Below line fixes it:
               cell2.DataBindings.Add("Text", null, tableName + "." + columns[i].FieldName);  
(3) Could you please show example of sumary row/column as well?
E.g., lastcol = col5 + col6 + col7,
lastRow(col5) = sum(col5), etc.

Added By: Leon Zeng at: 9/19/2014 6:36:03 AM    

code snipet of my test below.  

       private void InitTables(List<GridColumn> columns)
       {
           int colCount = columns.Count;
           int bodyWidth = (PageWidth - (Margins.Left + Margins.Right));
    
           //header
           XRTable table = new XRTable();
           XRTableRow row = new XRTableRow();
           //cells
           XRTable table2 = new XRTable();
           XRTableRow row2 = new XRTableRow();
           for (int i = 0; i < colCount; i++)
           {
               XRTableCell cell = new XRTableCell();
               cell.Width = (int)columns[i].Width;
               cell.Text = columns[i].Caption;
               cell.Font = new Font(cell.Font, FontStyle.Bold);
               if (i > 0)
                   cell.Borders = BorderSide.Top | BorderSide.Right | BorderSide.Bottom;
               else
                   cell.Borders = BorderSide.All;
               cell.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
               row.Cells.Add(cell);

               XRTableCell cell2 = new XRTableCell();
               if (i > 0)
                   cell2.Borders = BorderSide.Right | BorderSide.Bottom;
               else
                   cell2.Borders = BorderSide.Right | BorderSide.Bottom | BorderSide.Left;
               cell2.Padding = new PaddingInfo(5, 5, 5, 5);
               cell2.Width = columns[i].Width;
               cell2.DataBindings.Add("Text", null, tableName + "." + columns[i].FieldName);
               if(columns[i].OptionsColumn.AllowMerge == DevExpress.Utils.DefaultBoolean.True)
                   cell2.ProcessDuplicates = DevExpress.XtraReports.UI.ValueSuppressType.MergeByValue;
               row2.Cells.Add(cell2);

           }

           table.Rows.Add(row);
           table.Width = bodyWidth;

           table2.Rows.Add(row2);
           table2.Width = bodyWidth;

           Bands[BandKind.PageHeader].Controls.Add(table);
           Bands[BandKind.Detail].Controls.Add(table2);
           for (int i = 0; i < colCount; i++)
           {
               if (columns[i].SummaryItem.SummaryType != null)
               {
                   showSummaryRow = true;
                   break;
               }
           }

           if (showSummaryRow)
           {
               XRTable table3 = new XRTable();
               XRTableRow row3 = new XRTableRow();
               table3.Rows.Add(row3);
               table3.Width = bodyWidth;

               for (int i = 0; i < colCount; i++)
               {
                   //summary

                   XRTableCell cell3 = new XRTableCell();
                   cell3.Padding = new PaddingInfo(5, 5, 5, 5);
                   cell3.Width = columns[i].Width;
                   cell3.BackColor = System.Drawing.Color.AliceBlue;

                   if (i > 0)
                   {
                       cell3.Borders = BorderSide.Right | BorderSide.Bottom;
                       cell3.DataBindings.Add("Text", null, tableName + "." + columns[i].FieldName);
                       DevExpress.XtraReports.UI.XRSummary xrSummary = new DevExpress.XtraReports.UI.XRSummary();
                       xrSummary.FormatString = "{0:#}";
                       xrSummary.Running = DevExpress.XtraReports.UI.SummaryRunning.Report;
                       xrSummary.Func = getFunc(columns[i].SummaryItem.SummaryType);
                       cell3.Summary = xrSummary;
                   }
                   else
                   {
                       cell3.Borders = BorderSide.Right | BorderSide.Bottom | BorderSide.Left;
                       cell3.Text = "合计";
                   }
                   row3.Cells.Add(cell3);
               }
               Bands[BandKind.ReportFooter].Controls.Add(table3);
           }
       }

       private DevExpress.XtraReports.UI.SummaryFunc getFunc(SummaryItemType type){
           switch (type)
           {
               case SummaryItemType.Sum: return SummaryFunc.Sum;
               case SummaryItemType.Count: return SummaryFunc.Count;
               case SummaryItemType.Average: return SummaryFunc.Avg;
               case SummaryItemType.Max: return SummaryFunc.Max;
               case SummaryItemType.Min: return SummaryFunc.Min;
               default: return SummaryFunc.Count;
           }
       }

ASPxGridView - How to save selected rows to the database by using WebMethods

$
0
0

This example shows how to save and retrieve selection state of the row. It is realized by using WebMethods. On page loading, selection state is retrieved from the database and ASPxGridView rows are selected by the SetSelection method. When a row is selected, the client-side ASPxClientGridView.SelectionChanged event is raised and the UpdateDB method is called. This method updates a database.
On the client side, WebMethod is called by

[JScript]
PageMethods.UpdateDB(array);

On the server side, ScriptManager is used with EnablePageMethods set in "True".

[ASPx]
<asp:ScriptManagerID="ScriptManager1"runat="server"EnablePageMethods="true"></asp:ScriptManager>

and the C# method is marked by WebMethodAttribute 

[C#]
usingSystem.Web.Services; [WebMethod]publicstaticvoidUpdateDB(object[]array){//method code}

 

See also:
ASPxGridView - How to save selected rows to the database when ProcessSelectionChangedOnServer is True
How to track progress of server side processing on the client side (using WebMethods)

How to preview a report in an ASP.NET MVC application

ASPxGridView - How to implement cascading comboboxes in Batch Edit mode by using WebMethods

$
0
0

This example shows how to implement cascading comboboxes in EditingSettings "Batch" mode by using WebMethods. Example is based on ASPxGridView - How to implement cascading comboboxes in Batch Edit mode and How to populate a cascading ASPxComboBox by using WebMethods examples. The main idea is to remove EditTemplate from ASPxGridView and replace ASPxComboBox Callback by WebMethods to refresh child's combobox item collection. This will improve server's response time and reduce server's load.

How Insert, Update and Delete ASPxGridView's records with buttons

$
0
0

To change ASPxGridView's data from the client side, there are appropriate ASPxClientGrid methods:

AddNewRow
DeleteRow
StartEditRow

To save or cancel changes, there are:
UpdateEdit
CancelEdit

The following example implements a custom defined toolbar with ASPxButtons, which perform all the editing capabilities over a grid's data source.

Note: to distinguish records, the property AllowFocusedRow should be enabled for grid.

See Also:
Switch to the edit mode by clicking a status bar button or by double-clicking a row
Editing an in-memory dataset
How to enable/disable command buttons on the client side

Question Comments

Added By: Matthew moore 3 at: 5/24/2012 6:08:25 AM    

I am having a hard time getting the buttons to work. Am i missing something on the backend which might stop it from working. Is there a place i can get more direction or post my code ?

Added By: BiBOARD BiBOARD at: 3/15/2016 8:21:01 AM    I tried this example, it does not work.
In fact the events: RowDeleting, RowInserting, RowUpdating, InitNewRow are not fired at all. Can you explain me what I miss?

Thanks
Added By: Vova (DevExpress Support) at: 3/15/2016 9:20:58 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T356923: ASPxGridView - The RowDeleting, RowInserting, RowUpdating and InitNewRow events aren't fired. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

How to populate a cascading ASPxComboBox by using WebMethods

$
0
0

This example explains how to populate a cascading ASPxComboBox by using WebMethods. On the client side, the master ASPxComboBox is subscribed to the SelectedIndexChanged event. When the event is raised, it sends a request to the server by WebMethod. If the request is successful, a child ASPxComboBox is populated with the response object.

On the client side, WebMethod is called by the following code:

[JScript]
PageMethods.GetData(id, OnSuccess);

On the server side, ScriptManager is used with EnablePageMethods set to "True":

[ASPx]
<asp:ScriptManagerID="ScriptManager1"runat="server"EnablePageMethods="true"></asp:ScriptManager>

The C# method is marked by WebMethodAttribute:

[C#]
usingSystem.Web.Services;[WebMethod]publicstaticList<Product>GetData(stringcategoryID){//method code}



How to generate a sequential and user-friendly identifier field within an XPO 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. If you have validation rules for your business class, the OnSaving method (and thus the sequence generation) is called only after all validation is passed. However, in rare cases, if a database related error is thrown during the first save and then the form is re-saved, the OnSaving method may be called again and a new sequence can be generated. This may lead to gaps in sequential numbers, which is not always allowed by business requirements (e.g., government regulations). To avoid this, you can use a more complicated solution from 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 or implement a database-level solution to handle such situations (e.g., using triggers).

3. 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.Added By: MohammedFarooq at: 10/14/2015 5:03:57 AM    

You hit a bull's eye! I didn't have the  if(string.IsNullOrEmpty(Code)) in my code.

Was it added recently? Because i followed this example before and somehow i missed it.

Added By: Dennis (DevExpress Support) at: 10/14/2015 5:18:38 AM    You're always welcome. AFAIK, I added it a year ago or so.Added By: Paul Kubb at: 3/16/2016 2:14:58 AM    Would you please describe more in detail about serverprefix table? how and when to use it?
I cannot find any documentation about it also.

How to define a custom Filter Popup allowing to add custom toolbar buttons

$
0
0

To accomplish this task, define a custom PivotGridField.HeaderTemplate. In the attached solution, this template is defined in the MainWindow.xaml file. The custom functionality is implemented in the ComboBoxEdit descendant. This descendant is defined in the CustomFilterPopup.cs file. Filter popup is populated from the PivotGridRadioFilter_PopupOpening event handler. To apply filter, the PivotGridRadioFilter_PopupClosed event handler is used. 
To demonstrate how to add custom functionality, the Invert command is defined. 

How to make the auto filter row's filter accent insensitive

$
0
0

This example demonstrates how to create a custom function that removes all diacritic symbols from the specified string value. Using the GridView.SubstituteFilter event, this function can be injected into the active grid filter.

The SubstituteFilter event was added in version 2015 vol 1. To accomplish this task in older version, create a custom grid and customize the mechanism of filtering data via the auto filter row. For this, the GridView.RaiseCustomRowFilter method can be overridden. In this method, the cell text and filter string should be normalized via the standard String.Normalize method and then the cell value is processed based on the comparison operator type returned via the OptionsColumnFilter.AutoFilterCondition property.

How to: Store file attachments in the file system instead of the database

$
0
0

Scenario
The FileSystemData module provides the FileSystemStoreObject and FileSystemLinkObject classes that implement the IFileData interface for the use with our File Attachments module.
FileSystemStoreObject - this class enables you to store uploaded files in a centralized file system location instead of the database. You can configure the file system store location via the static FileSystemDataModule.FileSystemStoreLocation property.
FileSystemLinkObject - this class enables you to add soft links to real files instead of saving their contents to the database. Apparently, it is intended for use in Windows Forms applications only.

Refer to the following video to see this functionality in action: http://www.screencast.com/t/Xl1GMfxw

Steps to implement
1. Copy and include the FileSystemData project into your solution and make sure it is built successfully.

2. Invoke the Module Designer for the YourSolutionName.Module/Module.xx file by double-clicking it in Solution Explorer. Invoke the Toolbox (Alt+X+T) and then drag & drop the FileSystemDataModule component into the modules list on the left.
3. Define a FileSystemStoreObject or FileSystemLinkObject type properties within your business class as described in the eXpressApp Framework > Task-Based Help > How to: Implement File Data Properties article. Make sure to decorate the container business class with the FileAttachmentAttribute to provide additional commands for working with files. See the E965.Module\BusinessObjects\FileSystemStoreObjectDemo.xx and E965.Module\BusinessObjects\FileSystemLinkObjectDemo.xx  source files for examples. 

4. Make sure you do not override the DevExpress.Persistent.BaseImpl.BaseObject.OidInitializationMode property in your application and related modules, because the OidInitializationMode.AfterConstruction value is necessary for the correct operation of this module (in the example, the required default value is already set in the FileSystemDataModule class of this example module).
5. Modify YourSolutionName.Win/WinApplication.xx file to handle the CustomOpenFileWithDefaultProgram event of the DevExpress.ExpressApp.FileAttachments.Win.FileAttachmentsWindowsFormsModule class as shown in the E965.Win\WinApplication.xx file.

 

IMPORTANT NOTES
1.
The current version of this example does not support the middle-tier scenario. Refer to the Q476039 ticket for more details.

 

See Also:
File Attachments Module Overview
Working with links to files instead of storing their contents in the database
SQL Server FILESTREAM feature Overview

Question Comments

Added By: Roger Gardner at: 8/2/2012 4:36:37 AM    

-How to change FileStoreObject to work With Application server?
-How many files you can store in one folder and the system is not to slow?

Can this sample be upgraded with Application server and multiple folders in File Data Store folder?

Added By: Sander Mclean at: 8/22/2012 12:31:10 AM    

Thank you for your example, but could you upgrade this to VB.NET?

Added By: Martin Kraeuchi at: 10/12/2012 2:00:24 AM    

I tried to run this example but it crashes.
It occurs a fatal error when I try to append a file after creating a new "Standard File Data Demo" Item. The error occurs at the moment the file select box opens. I didn't found a way to debug it.
Do you have a glue what it could be?

My configuration:
Win7 64BIT, VS2010, v2012 vol 1.7, SQL Server Express 2008 R2

Thanks, Martin

Added By: Dennis (DevExpress Support) at: 11/29/2012 9:56:43 AM    

@Roger: I have not yet tested this module with the application server. It is a good idea, though. Thank you for your input, I have added it to my TODO list.

@Sander: It is quite complex a module to rewrite it in VB.NET, as well as maintain two versions later. Even though it is not in my immediate plans, you can either include the C# module project into your VB.NET solution (Visual Studio allows this) or rather use free or paid conversion tools.

@Martin: Thank you for your comment. Hm, it performs perfectly well for me. I also ran functional tests that passed locally. You are probably not using the latest version in this example. It would be great if you could create a separate ticket in the Support Center and attach the eXpressAppFramework.log file with the error details. Thank you in advance!

PS.
Sorry for the late reply, guys. In the future, it is better to submit a ticket directly via the http://www.devexpress.com/Support/Center/Question/Create link, if you experienced any difficulties with our tools.

Added By: ABRAMO ABRAMO at: 11/21/2013 11:44:40 AM    

Hi,
I'm working with Images in XAF application storing user image file to file system. So I'm using FileSystemStoreObject and It work fine for me. However, I've some problem!

one - I'd like split and save user images in FileData\<mykey1> folder where mykey1 depends by Business Objects instance1,
user images in FileData\<mykey2> folder where mykey2 depends by Business Objects instance2 and so on.
two - I'd like show stored images like Asp.net Images Slides Control or a link item in grid view to open images.

Do you have any suggestion or example?

Best regards,
Gaetano

Added By: Ricardo Granja at: 1/27/2014 4:36:39 AM    

Do vou have an exemple of this as a domain componente?

Regards,
Ricardo

Added By: xaero xy at: 6/2/2014 9:47:03 PM    

Did the "StandardFileDataDemo" store file attachments in database?

Added By: Dennis (DevExpress Support) at: 6/3/2014 2:24:48 AM    

@xaero: The StandardFileDataDemo class uses the FileData class that stores files in the database and which is a part of the standard delivery.

In turn, the FileSystemStoreObjectDemo class stores files in the file system with the help of custom IFileData implementations described in this example.

Added By: Steve Perks @ NSS at: 9/19/2014 4:11:17 AM    

Hi Dennis, thank you for the code - it works great in my web application (I'm only using the FileSystemStoreObject). I've made a mod to cover the case where the user has previously saved a business object and subsequently reloads it to edit the FileSystemStoreObject property, namely to pick a different file. In this case _tempFileName is not correctly populated and the old file is not deleted when the file is changed and the business object saved.

My solution was to add the following code to FileSystemStoreObject.cs

   protected override void OnLoaded()
   {
       base.OnLoaded();
       _tempFileName = this.RealFileName;
   }

Hope this helps others and perhaps you could update your code if you also feel this is a good solution.

Added By: Dennis (DevExpress Support) at: 9/19/2014 5:21:49 AM    

Thanks for sharing, Steve. Would you please either record a video showing how to replicate this behavior with the original example or create a functional EasyTest script covering this scenario? This will help me better understand the situation and make changes, if necessary. Thanks in advance! 

Added By: Steve Perks @ NSS at: 9/19/2014 5:47:52 AM    

Dennis, how shall I send the video? No attachments in this thread.

Added By: Steve Perks @ NSS at: 9/19/2014 6:09:35 AM    

It's ok about sending the video, I've decided to host it for a short while here: http://host21.co.uk/e965/

Added By: Dennis (DevExpress Support) at: 9/19/2014 6:13:09 AM    Thanks for your video, Steve. I will take this scenario into account  for future updates.Added By: Genesis Supsup 1 at: 12/30/2015 2:07:35 AM    

Does this already work using Application Server? Given the correct credentials, will this concept work with Dropbox (in replacement to File System)?

Added By: Alexey (DevExpress Support) at: 12/30/2015 9:27:28 PM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T329782: E965 with dropbox. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Joseph Kellerer 2 at: 2/26/2016 4:17:30 AM    Thank you for providing this code!
It works great.

I have enhanced the FileSystemStoreObject to have a Content property like in the BaseImpl.FileData class:

[C#]
[NonPersistent]publicbyte[]Content{get{returnFile.ReadAllBytes(this.RealFileName);}set{this.TempSourceStream=newMemoryStream(value);}}
Added By: CHRIS TSELEBIS at: 3/16/2016 7:27:47 AM    The deletion is not working correctly on the detailview.  I hit delete, filed is deleted but gets an error message saying "requested objects canot be loaded, because they are abasent in the data store....".  It works fine in the listview.  Please check.

How to show an error message when a record cannot be deleted

$
0
0

This example demonstrates how to show an error message when an attempt to delete a record is cancelled by the RowDeleting event handler.

Question Comments

Added By: Rabab Siblini at: 3/16/2016 11:18:39 PM    Tanks, it works exactly as I want , but I didn't user the exception class , I check it as such :

 protected void gvDiscounts_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)        {            if (CannotDelete)                throw new Exception("DeleteError");        }

  protected void gvDiscounts_CustomErrorText(object sender, ASPxGridViewCustomErrorTextEventArgs e)        {            if (e.Exception.Message == "DeleteError")                e.ErrorText = e.Exception.Message;        } Added By: Vova (DevExpress Support) at: 3/17/2016 1:57:07 AM    

Thank you for sharing your idea with our community, Rabab. It may be useful for other users trying to complete a similar task.

Best regards,
Vova

Viewing all 7205 articles
Browse latest View live


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