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

How to replace the default Filter Popup with a custom one made with ASPxGridView control

$
0
0

This example demonstrates how to replace the default Filter Popup with a custom one made with the ASPxGridView control. This solution demonstrates only a basic approach, and it is possible to customize it further to achieve a custom result. The whole sample functionality can be divided into three parts:

1. We use the ASPxPivotGrid.FieldValueTemplate property to assign a custom header template. You can use a simpler sample project demonstrating this approach in the Create Header or Field Value Templates and replicate existing look-and-feel example. Note that in this example we replace the default filter button with a custom one created dynamically.


2. To get information about the filter applied to a specific field, we use the PivotGridFieldBase.FilterValues and PivotGridFieldBase.GetUniqueValues properties. To pass filter information from the server to the client, we simply convert filter values to strings. This solution can be not enough in some situations. In this case, it might be necessary to update the code accordingly.


3. To populate ASPxGridView with data at runtime and apply the specified filter to the ASPxPivotGrid control, we use the ASPxClientPivotGrid.PerformCallback and ASPxClientGridView.PerformCallback methods. The client-side row selection functionality is provided by the ASPxGridView's built-in Selection feature.


Question Comments

Added By: Nagamanickam Rajamanickam at: 1/29/2014 10:36:06 AM    

Hello Team,

We have implemented a CustomFilterPopup using this sample, but how to set this Custom Filter Popup only for one item and leave the others as default Pivot Grid Filter Popups?

Thanks
Naga

Added By: mush at: 5/7/2014 5:18:41 AM    

Hi,

I am trying to implement this approach, but Paging is not working. could you please let me know how paging will work here.


GridView - How to show LoadingPanel during export

$
0
0

When you export a grid with a lage amount of data, you might want to show the LoadingPanel during exporting. To do so, handle the button's client-side Click event to:

1) Show the loading panel;

2) Perform an ajax request to the server to export the grid;

3) Hide the loading panel on success and submit the form to attach the exported document to the response.

[JScript]
   function OnClick(s, e){        $.ajax({            url: '@Url.Action("CallbackExport", "Home")',             type: "POST",             data: $("#form").serialize(),             beforeSend: (function(data){                LoadingPanel.Show();           })       }).done(function(data){            LoadingPanel.Hide();            $("#form").submit();       });   }

See Also:
How to show ASPxLoadingPanel during export

How to export ASPxDataView control content to a PDF file

$
0
0

This example demonstrates how to export ASPxDataView control content to a PDF file. Currently, ASPxDataView does not support data export, therefore we suggest a workaround with two ASPxDataViews. One of the two ASPxDataView's has ASPxDataView.ClientVisible set to False and we export its data, the second ASPxDataView is only used to display data we export. In this example, we also use the ASPxHiddenField control to transfer data from the client side to the server. We handle the following events:  ASPxDataView.CustomCallbackASPxClientDataView.BeginCallbackASPxClientDataView.EndCallbackASPxButton.ClickASPxClientButton.Click.

First, we send a callback to an invisible ASPxDataView on ASPxClientButton.Click, then ASPxDataView html is obtained and written to ASPxHiddenField for each page on ASPxClientDataView.BeginCallback. Finally, a next callback is sent by handling the ASPxClientDataView.EndCallback event. The html-markup of every ASPxDataView page is first written to the session and then to a response using RichEditDocumentServer component on the server side.

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.

Inserting a new row in ASPxGridView with the image preview enabled

How to use a stored procedure with parameters as a report data source in a Web application

$
0
0

To allow passing a procedure parameter to an XtraReport descendant class (XtraReport1), it's updated with an argument which is used while populating the DataSet instance.
On the web page, a DropDownList control is placed, which is populated with the list of parameters.
In the example, the "CustOrdersOrders" stored procedure (Northwind database) with the "CustomerID" parameter is used, so the DropDownList contains every CustomerID from the Customers table.

Within the Page_Load event handler, the ReportViewer.Report property is updated using a newly created report instance.

Question Comments

Added By: Jay Johnson at: 6/14/2012 2:26:38 PM    

Is there any "How To" for this? It seems to contradict other examples which use _BeforePrint

Is part of this example missing?

Added By: Mark D Loaney at: 6/20/2012 3:59:08 AM    

I've been wasting days trying to get this working, it appears that when I pass the parameters in the system breaks. I have a procedure that has the following parameters:

 @OrganisationID INT = 0,
    @Key INT = 3,
    @WeekStarting DATE = NULL,
    @WeekEnding DATE = NULL,
    @DivisionID INT = 0,
    @WorkgroupID INT = 0,
    @EmployeeID INT = 281,
    @Factor FLOAT = 0.00000

of which I only really need Key, EmployeeID, Division and Workgroup

The 'New' in xtrareports is as follows (note if I comment out the parameters passed in it works with the detault values and returns data:

Public Sub New(ByVal mEmployeeID As Integer, ByVal mKey As Integer, ByVal Org As Integer, divsn As Integer, wrkgp As Integer)
        MyBase.New()

        'This call is required by the Designer.
        InitializeComponent()
        cpM_Reports_StaffTableAdapter1.Fill(Me.staff1.CPM_Reports_Staff, Convert.ToInt32(Org), Convert.ToInt32(mKey), Convert.ToDateTime(Now()), Convert.ToDateTime(Now()), Convert.ToInt32(divsn), Convert.ToInt32(wrkgp), Convert.ToInt32(mEmployeeID))

    End Sub

ie this works, but of course the parameters aren't there!

Public Sub New() 'ByVal mEmployeeID As Integer, ByVal mKey As Integer, ByVal Org As Integer, divsn As Integer, wrkgp As Integer)
        MyBase.New()

        'This call is required by the Designer.
        InitializeComponent()
        'cpM_Reports_StaffTableAdapter1.Fill(Me.staff1.CPM_Reports_Staff, Convert.ToInt32(Org), Convert.ToInt32(mKey), Convert.ToDateTime(Now()), Convert.ToDateTime(Now()), Convert.ToInt32(divsn), Convert.ToInt32(wrkgp), Convert.ToInt32(mEmployeeID))

    End Sub

The proper values are coming in to the system when I put in a breakpoint - seems that the initialise isn't firing??

The code on the webform is

  Dim Division As Integer = 0
            Dim Workgroup As Integer = 0
            Dim Key As Integer = lstFilter.SelectedIndex
            If IsNumeric(lstDivision.SelectedValue) Then Division = CInt(lstDivision.SelectedValue)
            If IsNumeric(lstWorkgroup.SelectedValue) Then Workgroup = lstWorkgroup.SelectedValue
            Dim report As New XStaffActivity(Helpers.EmployeeID, Key, Helpers.MyCompanyID, Division, Workgroup)
            rvStaffActivity.Report = report

Help please (PS I've copied the full xtrareports code below (cutting out the 60 off labels etc on there):

Imports System
Imports DevExpress.XtraReports.UI
Imports System.Drawing.Printing
Public Class XStaffActivity
    Inherits DevExpress.XtraReports.UI.XtraReport

#Region " Designer generated code "

    Public Sub New(ByVal mEmployeeID As Integer, ByVal mKey As Integer, ByVal Org As Integer, divsn As Integer, wrkgp As Integer)
        MyBase.New()

        'This call is required by the Designer.
        InitializeComponent()
        cpM_Reports_StaffTableAdapter1.Fill(Me.staff1.CPM_Reports_Staff, Convert.ToInt32(Org), Convert.ToInt32(mKey), _
                                            Convert.ToDateTime(Now()), Convert.ToDateTime(Now()), Convert.ToInt32(divsn), _
                                            Convert.ToInt32(wrkgp), Convert.ToInt32(mEmployeeID))

    End Sub

    'XtraReport overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing AndAlso components IsNot Nothing Then
            components.Dispose()
        End If
        MyBase.Dispose(disposing)
    End Sub
    Private WithEvents staff1 As Staff
    Private WithEvents cpM_Reports_StaffTableAdapter1 As StaffTableAdapters.CPM_Reports_StaffTableAdapter
    Private WithEvents groupHeaderBand1 As DevExpress.XtraReports.UI.GroupHeaderBand
    Private WithEvents xrLabel2 As DevExpress.XtraReports.UI.XRLabel
    Private WithEvents groupHeaderBand2 As DevExpress.XtraReports.UI.GroupHeaderBand
    Private WithEvents xrLabel4 As DevExpress.XtraReports.UI.XRLabel
    Private WithEvents groupHeaderBand3 As DevExpress.XtraReports.UI.GroupHeaderBand Private WithEvents xrPageInfo1 As DevExpress.XtraReports.UI.XRPageInfo
    Private WithEvents xrPageInfo2 As DevExpress.XtraReports.UI.XRPageInfo
    Private WithEvents reportHeaderBand1 As DevExpress.XtraReports.UI.ReportHeaderBand
    Private WithEvents xrLabel23 As DevExpress.XtraReports.UI.XRLabel
    Private WithEvents groupFooterBand1 As DevExpress.XtraReports.UI.GroupFooterBand
    Private WithEvents groupFooterBand2 As DevExpress.XtraReports.UI.GroupFooterBand
    Private WithEvents xrLabel24 As DevExpress.XtraReports.UI.XRLabel
      Private WithEvents Title As DevExpress.XtraReports.UI.XRControlStyle
    Private WithEvents FieldCaption As DevExpress.XtraReports.UI.XRControlStyle
    Private WithEvents PageInfo As DevExpress.XtraReports.UI.XRControlStyle
    Private WithEvents DataField As DevExpress.XtraReports.UI.XRControlStyle
    Private WithEvents topMarginBand1 As DevExpress.XtraReports.UI.TopMarginBand
    Private WithEvents bottomMarginBand1 As DevExpress.XtraReports.UI.BottomMarginBand
    'Required by the Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Designer
    'It can be modified using the Designer.
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Dim resourceFileName As String = "XStaffActivity.resx"
        Dim xrSummary1 As DevExpress.XtraReports.UI.XRSummary = New DevExpress.XtraReports.UI.XRSummary()
Dim xrSummary33 As DevExpress.XtraReports.UI.XRSummary = New DevExpress.XtraReports.UI.XRSummary()
        Me.Detail = New DevExpress.XtraReports.UI.DetailBand()
        Me.xrLabel60 = New DevExpress.XtraReports.UI.XRLabel()
        Me.xrVEmployee = New DevExpress.XtraReports.UI.XRLabel()
        Me.xrLabel51 = New DevExpress.XtraReports.UI.XRLabel()
        Me.xrLabel14 = New DevExpress.XtraReports.UI.XRLabel()
        Me.xrLabel15 = New DevExpress.XtraReports.UI.XRLabel()
        Me.xrLabel16 = New DevExpress.XtraReports.UI.XRLabel()
        Me.xrLabel17 = New DevExpress.XtraReports.UI.XRLabel()
        Me.xrLabel18 = New DevExpress.XtraReports.UI.XRLabel()
        Me.xrLabel19 = New DevExpress.XtraReports.UI.XRLabel()
        Me.xrLabel20 = New DevExpress.XtraReports.UI.XRLabel()
        Me.xrLabel21 = New DevExpress.XtraReports.UI.XRLabel()
        Me.xrLabel22 = New DevExpress.XtraReports.UI.XRLabel()
        Me.staff1 = New Staff()
        Me.cpM_Reports_StaffTableAdapter1 = New StaffTableAdapters.CPM_Reports_StaffTableAdapter() Me.Title = New DevExpress.XtraReports.UI.XRControlStyle()
        Me.FieldCaption = New DevExpress.XtraReports.UI.XRControlStyle()
        Me.PageInfo = New DevExpress.XtraReports.UI.XRControlStyle()
        Me.DataField = New DevExpress.XtraReports.UI.XRControlStyle()
        Me.topMarginBand1 = New DevExpress.XtraReports.UI.TopMarginBand()
        Me.bottomMarginBand1 = New DevExpress.XtraReports.UI.BottomMarginBand()
        CType(Me.staff1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me, System.ComponentModel.ISupportInitialize).BeginInit()
        '
        'Detail
        '
        Me.Detail.Controls.AddRange(New DevExpress.XtraReports.UI.XRControl() {Me.xrLabel60, Me.xrVEmployee, Me.xrLabel51, Me.xrLabel14, Me.xrLabel15, Me.xrLabel16, Me.xrLabel17, Me.xrLabel18, Me.xrLabel19, Me.xrLabel20, Me.xrLabel21, Me.xrLabel22})
        Me.Detail.HeightF = 17.0!
        Me.Detail.Name = "Detail"
        Me.Detail.Padding = New DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 100.0!)
        Me.Detail.StyleName = "DataField"
        Me.Detail.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft
        '
             'Title
        '
        Me.Title.BackColor = System.Drawing.Color.Transparent
        Me.Title.BorderColor = System.Drawing.Color.Black
        Me.Title.Borders = DevExpress.XtraPrinting.BorderSide.None
        Me.Title.BorderWidth = 1
        Me.Title.Font = New System.Drawing.Font("Arial Narrow", 21.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Title.ForeColor = System.Drawing.Color.Black
        Me.Title.Name = "Title"
        '
        'FieldCaption
        '
        Me.FieldCaption.BackColor = System.Drawing.Color.Transparent
        Me.FieldCaption.BorderColor = System.Drawing.Color.Black
        Me.FieldCaption.Borders = DevExpress.XtraPrinting.BorderSide.None
        Me.FieldCaption.BorderWidth = 1
        Me.FieldCaption.Font = New System.Drawing.Font("Arial Narrow", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.FieldCaption.ForeColor = System.Drawing.Color.Black
        Me.FieldCaption.Name = "FieldCaption"
        '
        'PageInfo
        '
        Me.PageInfo.BackColor = System.Drawing.Color.Transparent
        Me.PageInfo.BorderColor = System.Drawing.Color.Black
        Me.PageInfo.Borders = DevExpress.XtraPrinting.BorderSide.None
        Me.PageInfo.BorderWidth = 1
        Me.PageInfo.Font = New System.Drawing.Font("Arial", 8.0!)
        Me.PageInfo.ForeColor = System.Drawing.Color.Black
        Me.PageInfo.Name = "PageInfo"
        '
        'DataField
        '
        Me.DataField.BackColor = System.Drawing.Color.Transparent
        Me.DataField.BorderColor = System.Drawing.Color.Black
        Me.DataField.Borders = DevExpress.XtraPrinting.BorderSide.None
        Me.DataField.BorderWidth = 1
        Me.DataField.Font = New System.Drawing.Font("Arial", 9.0!)
        Me.DataField.ForeColor = System.Drawing.Color.Black
        Me.DataField.Name = "DataField"
        Me.DataField.Padding = New DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100.0!)
        '
        'topMarginBand1
        '
        Me.topMarginBand1.HeightF = 31.0!
        Me.topMarginBand1.Name = "topMarginBand1"
        '
        'bottomMarginBand1
        '
        Me.bottomMarginBand1.HeightF = 25.0!
        Me.bottomMarginBand1.Name = "bottomMarginBand1"
        '
        'XStaffActivity
        '
        Me.Bands.AddRange(New DevExpress.XtraReports.UI.Band() {Me.Detail, Me.groupHeaderBand1, Me.groupHeaderBand2, Me.groupHeaderBand3, Me.pageFooterBand1, Me.reportHeaderBand1, Me.groupFooterBand2, Me.groupFooterBand3, Me.reportFooterBand1, Me.topMarginBand1, Me.bottomMarginBand1})
        Me.DataAdapter = Me.cpM_Reports_StaffTableAdapter1
        Me.DataMember = "CPM_Reports_Staff"
        Me.DataSource = Me.staff1
        Me.Landscape = True
        Me.Margins = New System.Drawing.Printing.Margins(83, 55, 31, 25)
        Me.PageHeight = 850
        Me.PageWidth = 1100
        Me.StyleSheet.AddRange(New DevExpress.XtraReports.UI.XRControlStyle() {Me.Title, Me.FieldCaption, Me.PageInfo, Me.DataField})
        Me.Version = "12.1"
        CType(Me.staff1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me, System.ComponentModel.ISupportInitialize).EndInit()

    End Sub
    Friend WithEvents Detail As DevExpress.XtraReports.UI.DetailBand

#End Region

End Class

Added By: Mark D Loaney at: 6/21/2012 2:54:27 AM    

Never mind, problem solved, I wasn't passing the parameters in on everypost back - had the code in a 'on Not Page.IsPostBack Then ...

took it out of that and beautiful!!

Added By: Thue Møller Jensen at: 12/7/2012 5:39:38 AM    

Thansk a lot Mark to Mark for posting this last comment. After wasting a couple of days on this problem, i found this page with the solution.

Added By: Henry F. Wilson at: 5/7/2014 11:08:50 AM    

Truly grateful. I have spent days finding solution to this problem and this post solves. Thanks guys.

How to export GridView data to different rich 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!

ASPxGridView - How to show a confirmation dialog using ASPxPopupControl


How to implement a delete confirm dialog with a "don't ask me again" option

$
0
0

This example demonstrates how you can implement a round-cornered delete confirm dialog providing end-users with an option to prevent subsequent dialog displaying.

The confirm dialog is implemented using the ASPxPopupControl. It contains a WebUserControl representing the dialog content. The content's top control is the ASPxRoundPanel, which provides the round corner appearance of the dialog. Within its children, the ASPxRoundPanel contains an ASPxLabel control showing the ID value of the row to be deleted, two command ASPxButtons ("Yes", "No") and an ASPxCheckBox that, if checked, enables further delete operations to be performed without confirmation.

Pay your attention that in this example the "Don't ask confirmation" check box' value is stored within a client-side script variable ("dontAskConfirmation"). In a real-life application, it's recommended to preserve this value within a user-specific store such as user profile settings or cookies, for instance (you can take a look at the following blog to learn more: http://mattberseth.com/blog/2007/11/dont_ask_me_again_delete_confi.html).

Note that in this sample the following features and tricks are realized to make it work as expected:
- The ID value of the processed row is stored within a client script variable ("rowVisibleIndex");
- The ASPxPopupControl is made transparent to display its child ASPxRoundPanel as the dialog's immediate container;
- The ASPxPopupControl is used in modal mode and customized, so that it is always displayed centered within the ASPxGridView control (try to resize grid columns and invoke the dialog);
- The "Yes" button is made the dialog's default button (using the ASPxRoundPanel's DefaultButton property) to allow dialog submitting by pressing the Enter key. The "Yes" button programmatically receives input focus after the dialog is shown.

In this demo, the grid's data source is implemented within the TestData.cs file and a collection of data rows is stored within session. To reset the demo to its initial state, click the "Reload demo" button.

See Also:
How to include a deleted row KeyField value into the delete confirmation dialog
How to insert (or update) ASPxTreeList's row by clicking on an external button and delete rows with custom confirmation popup window
How to show a confirmation dialog using ASPxPopupControl

How to align an arrow to the left side of the DropDownButton control

$
0
0

This example demonstrates how to align an arrow to the left side of the DropDownButton control. 
This task can be accomplished by creating a custom control inherited from the DropDownButton class. The CustomDropDownButton class provides the ArrowAlignment property that allows setting arrow alignment to the left side of the control.

XtraForm - How to center-align a header caption text

How to create a TextEdit descendant that will display an image from an ImageCollection and provide a possibility of runtime image selection

$
0
0

This example shows how to create and use a TextEdit descendant that will display an image from an ImageCollection and provide the capability of runtime image selection.

This descendant's repository items have two additional properties:

RepositoryItems.ImageList - get or set an images source.
RepositoryItems.ImageIndex - get or set an index of the image that should be displayed.

And two additional events
RepositoryItems.IconClick - occurs when a user clicks on an image.
RepositoryItems.OnIconSelection - this event can be used to specify the index of the image that should be displayed. The event handler receives an argument of the OnIconSelectionEventArgs type for providing data related to this event.
The OnIconSelectionEventArgs has two properties.
ImageList - gets an image source specified in the RepositoryItems.ImageList property.
ImageIndex - gets or sets the index of the image that should be displayed.
You should assign the index of the image that you want to display to the OnIconSelectionEventArgs.ImageIndex property.

In the attached example the ImageCollection control is used for storing images. It is assigned to the RepositoryItems.ImageList properties of the created controls. The RepositoryItems.OnIconSelection event is used for the image selection according to the editor state. The RepositoryItems.IconClick event assigns the Form.Text property.

See Also:
How to force a TextEdit to display an image against the text

ASPxCombobox - How to implement filtering of a large data source

How to implement a custom LookUpEdit supporting Server Mode

$
0
0

The current LookUpEdit version does not allow using Server Mode datasources. This example demonstrates how to create a custom editor that allows using them.

Question Comments

Added By: Andrew Thornton at: 7/19/2013 10:32:51 AM    

Hi,

Just upgraded to 13.1.5, and this no longer compiles. Quite a few undocumented things looked to have changed.
Can we have a 13.4/5 version that works please?

Thanks.

Added By: Justin Zeng at: 4/17/2014 4:32:51 AM    

It seems many problem, can this function to be support in new version ?

Added By: Ivan (DevExpress Support) at: 4/27/2014 10:42:28 PM    

Hi Justin,

We cannot guarantee that this functionality will be available in the latest version. For now, you can try to extend this example manually. If you face difficulties doing this, do not hesitate to contact us.

Added By: Viktor Faerman at: 5/9/2014 1:57:04 AM    

Hi Alex,

how to implement this custom editor with MVVM?
Thanks, Viktor

Added By: Michael Ch (DevExpress Support) at: 5/9/2014 4:14:02 AM    Hello,

I have created a separate thread for your questions: How to implement a custom editor from the E4560 example with MVVM. Please refer to it for future discussion.

Thanks,
Michael

How to prevent altering the legacy database schema when creating an XAF application

$
0
0

Scenario
This example shows how to prevent altering the legacy database schema when creating an XAF application. Sometimes our customers want to connect their XAF applications to legacy databases, but they often have strong restrictions, which disallow making any changes in the legacy database schema, i.e. adding new tables, new columns. This is bad, because XAF creates the ModuleInfo table to use an application's version for internal purposes. XPO itself can add the XPObjectType table to correctly manage table hierarchies when one persistent object inherits another one. Usually, legacy databases contain plain tables that can be mapped to one persistent object. So, the XPObjectType table is not necessary in such scenarios.
However, one problem still remains: it is the additional ModuleInfo table added by XAF itself. The idea is to move the ModuleInfo and XPObjectType tables into a temporary database.

For this task we introduced a custom IDataStore implementation, which works as a proxy. This proxy receives all the requests from the application's Session objects to a data store, and redirects them to actual XPO data store objects based upon a table name that has been passed.

Steps to implement

1. In YourSolutionName.Module project create a custom IDataStore implementation as shown in the WinWebSolution.Module\XpoDataStoreProxy.xx file;

2. In YourSolutionName.Module project create a custom IXpoDataStoreProvider implementation as shown in the WinWebSolution.Module\XpoDataStoreProxyProvider.xx file;


3.
In YourSolutionName.Module project locate the ModuleBase descendant and modify it as shown in the WinWebSolution.Module\Module.xx file;

4. Define connection strings under the <connectionStrings> element in the configuration files of your WinForms and ASP.NET executable projects as shown in the WinWebSolution.Win\App.config and WinWebSolution.Win\Web.config files.

IMPORTANT NOTES
1. The approach shown here is intended for plain database tables (no inheritance between your persistent objects). If the classes you added violate this requirement, the exception will occur as expected, because it's impossible to perform a query between two different databases by default.
2. One of the limitations is that an object stored in one database cannot refer to an object stored in another database via a persistent property. Besides the fact that a criteria operator based on such a reference property cannot be evaluated, referenced objects are automatically loaded by XPO without involving the IDataStore.SelectData method. So, these queries cannot be redirected. As a workaround, you can implement a non-persistent reference property and use the Session.GetObjectByKey method to load a referenced object.
3. As an alternative to the demonstrated proxy solution you can consider joining data from several databases into a database view and then mapping persistent classes to that view: How to: Map a Database View to a Persistent Class.

See also:
How to implement XPO data models connected to different databases within a single application
How to: Use both Entity Framework and XPO in a Single Application


How to implement cascaded combo box columns in ASPxGridView without using templates

$
0
0

The example illustrates how to create an editable grid with cascaded combobox columns. The implementation of the example includes the handling of manual callbacks and providing items for appropriate arguments.
By default, the combobox column uses a datasource that displays all records to show a user Text values instead of record keys.

Question Comments

Added By: Deborah Carter at: 5/9/2014 3:45:18 AM    

I looked at the code below and it looks like what I have.  The page just never gets to it.  Here is the complete asp page:

<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="mnt_Person.aspx.vb" Inherits="mnt_Person" %>

<%@ Register assembly="DevExpress.Web.v13.2, Version=13.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridView" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.v13.2, Version=13.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dx" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
  <script type="text/javascript">
   // <![CDATA[
      var lastServiceDivNo = null;
      function OnServiceDivNoChanged(cmbServiceDivisionNm) {
          if (grid.GetEditor("ServiceAreaNm").InCallback())
              lastServiceDivNo = cmbServiceDivisionNm.GetValue().toString();
          else
              grid.GetEditor("ServiceAreaNm").PerformCallback(cmbServiceDivisionNm.GetValue().toString());
      }
      function OnEndCallback(s, e) {
          if (lastServiceDivNo) {
              grid.GetEditor("ServiceAreaNm").PerformCallback(lastServiceDivNo);
              lastServiceDivNo = null;
          }
      }
   // ]]>
   </script>
   <asp:Label ID="Label2" runat="server" CssClass="pageheader" Width="100%" Text="Supervisor Maintenance"></asp:Label>
   <br />
   <dx:ASPxGridView ID="grid" ClientInstanceName="grid" runat="server" AutoGenerateColumns="False"
       DataSourceID="SqlDataSource1" KeyFieldName="Person_Key">
       <Columns>
          <dx:GridViewCommandColumn ShowClearFilterButton="True" ShowNewButton="True"
               VisibleIndex="1">
           </dx:GridViewCommandColumn>
           <dx:GridViewDataTextColumn FieldName="Person_Key" VisibleIndex="2">
               <EditFormSettings Visible="False" />
           </dx:GridViewDataTextColumn>
           <dx:GridViewDataTextColumn FieldName="Supervisor_No" VisibleIndex="3">
           </dx:GridViewDataTextColumn>
           <dx:GridViewDataComboBoxColumn FieldName="ServiceDivisionNm" VisibleIndex="4">
               <PropertiesComboBox DataSourceID="SqlDataSource2" TextField="ServiceDivisionNm" EnableSynchronization="False"
                   ValueField="ServiceDivisionNo">
                    <ClientSideEvents SelectedIndexChanged="function(s, e) {OnServiceDivNoChanged(s); }"></ClientSideEvents>
                </PropertiesComboBox>
           </dx:GridViewDataComboBoxColumn>
           <dx:GridViewDataComboBoxColumn FieldName="ServiceAreaNm" VisibleIndex="5">
               <PropertiesComboBox EnableSynchronization="False">
               <ClientSideEvents EndCallback="OnEndCallback"></ClientSideEvents>
               </PropertiesComboBox>
           </dx:GridViewDataComboBoxColumn>
                       <dx:GridViewDataTextColumn FieldName="TransNoPrefix" VisibleIndex="8">
           </dx:GridViewDataTextColumn>
           <dx:GridViewDataTextColumn FieldName="Supervisor" VisibleIndex="9">
           </dx:GridViewDataTextColumn>
           <dx:GridViewDataCheckColumn FieldName="IsActive" VisibleIndex="10">
           </dx:GridViewDataCheckColumn>
       </Columns>
       <SettingsEditing Mode="Batch">
       </SettingsEditing>
       <Settings ShowFilterRow="True" />
       <SettingsCommandButton>
           <ClearFilterButton Text="Clear">
           </ClearFilterButton>
       </SettingsCommandButton>
       <SettingsDataSecurity AllowDelete="False" />
   </dx:ASPxGridView>
   

   <asp:SqlDataSource ID="SqlDataSource2" runat="server"
       ConnectionString="<%$ ConnectionStrings:CCFieldServiceConnectionString %>"
       SelectCommand="SELECT distinct [ServiceDivisionNo], [ServiceDivisionNm] FROM [dim_Organization]">
   </asp:SqlDataSource>
   
   <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:CCFieldServiceConnectionString %>"
       SelectCommand="SELECT distinct [ServiceAreaNo], [ServiceAreaNm] FROM [dim_Organization] WHERE ServiceDivisionNo = ? ">
       <SelectParameters>
           <asp:Parameter Name="?" />
       </SelectParameters>
   </asp:SqlDataSource>

   <asp:SqlDataSource ID="SqlDataSource1" runat="server"
       ConnectionString="<%$ ConnectionStrings:CCFieldServiceConnectionString %>"
       
       SelectCommand="SELECT dbo.dim_Person.Person_Key, dbo.dim_Person.Supervisor_No, dbo.dim_Person.TransNoPrefix, dbo.dim_Person.Supervisor, dbo.dim_Person.IsActive, dbo.dim_Organization.ServiceAreaNm, dbo.dim_Organization.ServiceDivisionNm FROM dbo.dim_Person INNER JOIN dbo.dim_Organization ON dbo.dim_Person.ServiceDivisionNo = dbo.dim_Organization.ServiceDivisionNo AND dbo.dim_Person.ServiceAreaNo = dbo.dim_Organization.ServiceAreaNo WHERE (dbo.dim_Person.IsActive = 1)">
     
   </asp:SqlDataSource>
   

</asp:Content>

Added By: Larry (DevExpress Support) at: 5/9/2014 5:31:02 AM    Hello Deborah,

So, I have created a separate ticket on your behalf to process your inquiry more effectively:

How to implement cascaded combo box columns in ASPxGridView without using templates

Please refer to it for further correspondence.

 

Use only one scroll bar for a grid with multiple master/detail levels.

$
0
0

A grid containing a number of groups (master), each with a number of lines (detail) is a representation of an order which is grouped for readability. When a group has a greater number of lines then fits on the screen, a scrollbar is added to the detail-view and when there are multiple groups the master-view also gets a scrollbar. When the user scrolls through the grid, only the master-view is scrolled (unless a row is selected, then only the detail-view is scrolled) and it feels like the program is behaving oddly, as half the rows are skipped.

To achieve this goal, we need the GridControl to have a height equal to the height of all content placed in a master-view. So, the scrollbar does not appear in either the master-view or in the detail-view. To allow scrolling, we need to put our GridControl into a XtraScrollableControl and set the GridControl.Dock property to DockStyle.Top.

We created the MyGridControl class - a descendant of the GridControl. MyGridControl works with MyGridView views and includes the CalcGridHeight() method, which is called when the appearance of the Master-View is changed.

To put MyGridControl in the XtraScrollableContainer, use the MyGridControl.InitScrolling() method at runtime.

Please note that if you want to change Bounds or Dock properties of MyGridControl at runtime, change similar properties of the MyGridControl.ScrollableContainer control.

Question Comments

Added By: Pascal Veilleux (Seika) at: 11/26/2012 7:29:29 PM    

The solution works great except that with that solution, since the XtraScrollableContainer contains the whole grid, we loose the header when we scroll so the user must scroll to the top to be able to sort, group, ...

Added By: Stécy at: 5/9/2014 6:14:11 AM    

Does not work if the grid is inside a layout control. How to fix?

ASPxFileManager - How to implement a List data bound custom file system provider

$
0
0

This example is based on the E2900: ASPxFileManager - How to implement a LINQ to SQL based file system provider code example.
It shows how to implement a custom file system provider that uses List as a data source. To persist data between requests, list is stored in Session.

Question Comments

Added By: Albert Rodriguez at: 5/9/2014 2:34:55 PM    

If the session state is store in SQL, this implementation will not work.  How do recommend to serialize the Session("DataSource")?

ASPxComboBox - How to change a color of text for certain items

$
0
0

This example illustrates how to customize a style for each item. Since the color is changed for an HTML element, it is necessary to synchronize this settings on each round-trip to the server. For this, handle the client-side combo box' Init and EndCallback event.

Note: the GetItemElement method is undocumented and can be changed without any notification with the next release.

Question Comments

Added By: Aris Vlotomas at: 5/12/2014 2:46:54 AM    

Hello,
I'm trying to use the following js code, without the for loop, but the listBox is null and the code is crashing.
var item1 = clientComboBox.listBox.GetItemElement(1).firstElementChild;

What can I do?
I just want to add/change styles for a specific item.

Thanks,
Aris

Added By: Larry (DevExpress Support) at: 5/12/2014 6:53:23 AM    

Hello Aris,

I have created a separate ticket on your behalf to process your inquiry more effectively:

ASPxComboBox - How to change a color of text for certain items (E4100 example)

Please refer to it for further correspondence.

How to customize the "Insert Merge Field" menu

$
0
0

This example illustrates how to customize the "Insert Merge Field" menu to group merge field names with identical prefixes (Employees and Customers in this example) into submenus. Note that we completely replace built-in InsertMergeFieldItem with a custom one. You can find its implementation in the CustomInsertMergeFieldItem.cs (CustomInsertMergeFieldItem.vb for VB.NET) code file. We are creating a PopupMenu Class instance and populating it with menu items/subitems on the fly. The field names of the datasource are obtained with help of a special DataBindingController class.

Finally, the actual merge field insertion is accomplished in the CustomInsertMergeFieldMenuItem'sOnClick method. Take a moment to look at the Create DOCVARIABLE in code and How to create nested fields programmatically code example to learn more on this subject.

Take note of a CustomInsertMergeFieldItem'sOnClick method. It delegates handling to the regular ShowInsertMergeFieldFormCommand. You can implement and display your own dialog here if necessary.

Here is a screenshot that illustrates a sample application in action:

Question Comments

Added By: Hampus Nilsson at: 5/12/2014 5:20:56 AM    

How is this done for the WPF based version of RichEdit?

Added By: Yulia (DevExpress Support) at: 5/12/2014 7:57:52 AM    Hi Hampus,
I have created a separate ticket on your behalf: How to customize the "Insert Merge Field" menu. We will answer you there.
Viewing all 7205 articles
Browse latest View live


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