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

How to create and populate an unbound column

$
0
0

GridView does not cache values of an unbound column, because it is impossible to determine when the cache should be cleared automatically. GridView just displays values provided by the CustomUnboundColumnData event. So, to display a specific value in a cell, you need to pass a corresponding value to the e.Value parameter based on a processed column and row. What you return as the e.Value parameter is what is displayed in GridView. Each time a cell needs to be updated, the CustomUnboundColumnData event is called.

This example demonstrates how a simple caching mechanism can be implemented. In this project, you can perform all supported operations with GridView, such as sorting/deleting/adding records, and the unbound column will display proper values. This is because values of the ID column are used as key values. This column is readonly and contains only unique values. So, rows can be always identified.

Question Comments

Added By: DevInfox at: 11/24/2012 3:13:02 PM    

When using code I get following error
Error     1     'InitializeComponent' is not declared. It may be inaccessible due to its protection level.     C:\Users\Boris\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb     32     13     WindowsApplication1
Error     2     'gridControl1' is not declared. It may be inaccessible due to its protection level.     C:\Users\Boris\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb     34     13     WindowsApplication1
Error     3     'gridView1' is not declared. It may be inaccessible due to its protection level.     C:\Users\Boris\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb     38     37     WindowsApplication1
Error     4     Handles clause requires a WithEvents variable defined in the containing type or one of its base types.     C:\Users\Boris\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb     44     156     WindowsApplication1
 Please advice

Added By: Mathias Tenaye Sahile at: 12/24/2014 12:54:27 AM    

i tried but was not sucessfull when is this
   Private Sub gridView1_CustomUnboundColumnData(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs) Handles gridView1.CustomUnboundColumnData
           If e.IsGetData Then
               e.Value = _Cache.GetValue(e.Row)
           End If
           If e.IsSetData Then
               _Cache.SetValue(e.Row, e.Value)
           End If
       End Sub
called do and how

Added By: Olga (DevExpress Support) at: 12/24/2014 2:18:48 AM    Hello,
As I can see, you've created a separate ticket on this subject. I've moved your comment there. Let's continue our discussion in that thread.Added By: Paul Riddell at: 1/5/2015 9:44:49 AM    

Hi are there any examples of this using an xpcollection of xpobjects as the datasource?

Added By: Dimitros (DevExpress Support) at: 1/6/2015 3:24:00 AM    

Hello Johnathon ,

To process your recent post more efficiently, I created a separate ticket on your behalf: T193371: Unbound column - how to use with XPCollection. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Dirk Dumon 1 at: 5/28/2015 12:43:44 AM    

Hi, I tried implementing this but the method gridView1_CustomUnboundColumnData is never triggered with IsSetData = true.
Only IsGetData is triggered.
In this regard, I found https://www.devexpress.com/Support/Center/Question/Details/CB65344
So, is this sample not correct or is there a way to get the IsSetData to work?

Added By: Nadezhda (DevExpress Support) at: 5/28/2015 2:26:29 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: How to set the CustomColumnDataEventArgs.IsSetData property to true . This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Nguyen Bac 1 at: 5/9/2016 10:08:51 PM    I have a problem with MyCach class. I don't know how to write this class. 
Please!
Added By: Andrew Ser (DevExpress Support) at: 5/10/2016 2:18:09 AM    Hello,

Here is an example illustrating the implementation of the MyCache class. Select it in the combo box as shown below:



ASPxMenu - How to bind a control to a database

$
0
0

This sample shows how to bind the ASPxMenu to data stored in a database.

Question Comments

Added By: ATIG at: 5/21/2013 12:44:50 AM    

protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BuildMenu(ASPxMenu1);
                BuildMenu(ASPxMenu3);
            }
        }

        protected void BuildMenu(ASPxMenu menu)
        {
            String sql = "select * from menus where Menu_Level = 0 and Menu_Status = 1";
            cMenus oMenus = new cMenus();
            DataSet ds = oMenus.GetRecordsToDs(sql);
            Int32 menu_id;
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                menu_id = Convert.ToInt32(row["Menu_Id"]);
                DevExpress.Web.ASPxMenu.MenuItem item = menu.RootItem.Items.Add();
                item.Name = Convert.ToString(row["Menu_Name"]);
                item.Text = Convert.ToString(row["Menu_Name"]);
                DataSet iDs = GetGroupItems(menu_id);
                for (int i = 0; i < iDs.Tables[0].Rows.Count; i++)
                {
                    DevExpress.Web.ASPxMenu.MenuItem ChildItem = new DevExpress.Web.ASPxMenu.MenuItem();
                    ChildItem.Name = iDs.Tables[0].Rows[i]["Menu_Name"].ToString();
                    ChildItem.Text = iDs.Tables[0].Rows[i]["Menu_Name"].ToString();
                    ChildItem.NavigateUrl = iDs.Tables[0].Rows[i]["Menu_SeoUrl"].ToString();
                    item.Items.Add(ChildItem);
                }
            }
        }

        private DataSet GetGroupItems(Int32 menu_id)
        {
            cMenus oMenus = new cMenus();
            String sql = "select * from menus where Menu_Level = 1 and Menu_Sub = " + menu_id + " order by Menu_Sort";
            DataSet ds = oMenus.GetRecordsToDs(sql);
            return ds;
        }

        public DataSet GetRecordsToDs(String sqlStr)
        {
            IDbConnection Conn = (IDbConnection)new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString);
            Conn.Open();
            IDbCommand dbCommand = new SqlCommand();
            dbCommand.CommandText = sqlStr;
            dbCommand.Connection = Conn;
            IDbDataAdapter dataAdapter = (IDbDataAdapter)new SqlDataAdapter();
            dataAdapter.SelectCommand = dbCommand;
            DataSet ds = new DataSet();
            dataAdapter.Fill(ds);
            Conn.Close();
            return ds;
        }

Added By: Nic Carreira at: 10/23/2013 10:40:20 AM    

I had a question on this.
Could someone explain how the child items are getting added to the menu?

For the root items menu.Items.Add(item) makes sense to me.

I understand menuItems.Add(itemID, item) does this somehow but how does that method know which menu to add the items too?

Thanks
Nic

Added By: Anthony (DevExpress Support) at: 10/24/2013 4:02:07 AM    

Hello Nic,

The menuItems dictionary contains MenuItem objects. Since root items are already added to the menu control, and the subitem added to the root item (that we obtain from the dictionary by key) automatically becomes a part of the whole hierarchy.

Added By: Nic Carreira at: 10/24/2013 10:21:53 AM    

Ok, this makes sense now.

Thanks

Added By: Dale Jensen Lodge at: 5/10/2016 11:53:59 PM    Hi it would be good to get sight of the underlying table that this code is referencing so we can see exactly what it's looking at. Thanks
Added By: Artem (DevExpress Support) at: 5/11/2016 12:34:13 AM    

Hi Dale,

I see you asked this question in the https://www.devexpress.com/Support/Center/Example/Details/E49 thread. Please refer to it for further correspondence.

ASPxGridView - Batch Editing - A simple implementation of an EditItemTemplate

$
0
0

This example demonstrates how to create a custom editor inside column's DataItem template when ASPxGridView is in Batch Edit mode. Since, ASPxGridView performs batch editing on the client side, we cannot process or pass values from editors placed inside templates on the server side. Thus, all processing will be performed on the client side. 


You can implement the EditItem template for a column by performing the following steps:

1. Specify column's EditItem template:

[ASPx]
<dx:GridViewDataColumnFieldName="C1"><EditItemTemplate>   <dx:ASPxSpinEditID="C1_spinEdit"runat="server"ClientInstanceName="C1spinEdit"Width="100%">   </dx:ASPxSpinEdit></EditItemTemplate></dx:GridViewDataColumn>


2. Handle grid's client-side BatchEditStartEditing event to set the grid's cell values to the editor. It is possible to get the focused cell value using the e.rowValues property:

[JScript]
       function Grid_BatchEditStartEditing(s, e){           var productNameColumn = s.GetColumnByField("C1");           if(!e.rowValues.hasOwnProperty(productNameColumn.index))               return;           var cellInfo = e.rowValues[productNameColumn.index];            C1spinEdit.SetValue(cellInfo.value);           if(e.focusedColumn === productNameColumn)                C1spinEdit.SetFocus();       }


3. Handle the BatchEditEndEditing event to pass the value entered in the editor to the grid's cell:

[JScript]
function Grid_BatchEditEndEditing(s, e){var productNameColumn = s.GetColumnByField("C1");if(!e.rowValues.hasOwnProperty(productNameColumn.index))return;var cellInfo = e.rowValues[productNameColumn.index]; cellInfo.value = C1spinEdit.GetValue(); cellInfo.text = C1spinEdit.GetText(); C1spinEdit.SetValue(null);}

 

4. The BatchEditRowValidating event allows validating the grid's cell based on the entered value:

[JScript]
function Grid_BatchEditRowValidating(s, e){var productNameColumn = s.GetColumnByField("C1");var cellValidationInfo = e.validationInfo[productNameColumn.index];if(!cellValidationInfo)return;var value = cellValidationInfo.value;if(!ASPxClientUtils.IsExists(value) || ASPxClientUtils.Trim(value) === ""){ cellValidationInfo.isValid = false; cellValidationInfo.errorText = "C1 is required";}}

 
5. Finally, handle the editor's client-side KeyDown and LostFocus events to emulate the behavior of standard grid editors when an end-user uses a keyboard or mouse:

[JScript]
var preventEndEditOnLostFocus = false;function C1spinEdit_KeyDown(s, e){var keyCode = ASPxClientUtils.GetKeyCode(e.htmlEvent);if(keyCode !== ASPxKey.Tab && keyCode !== ASPxKey.Enter)return;var moveActionName = e.htmlEvent.shiftKey ? "MoveFocusBackward" : "MoveFocusForward";if(grid.batchEditApi[moveActionName]()){ ASPxClientUtils.PreventEventAndBubble(e.htmlEvent); preventEndEditOnLostFocus = true;}}function C1spinEdit_LostFocus(s, e){if(!preventEndEditOnLostFocus) grid.batchEditApi.EndEdit(); preventEndEditOnLostFocus = false;}

 
See Also:
GridView - Batch Editing - A simple implementation of an EditItem template 


How to control state when the Session is being expired and prolong it on demand

$
0
0

This example illustrates how to create a timeout control for web sites (similar to what banks and other financial institutions have) that will display a modal popup dialog displaying the time remaining before a session is timed out and redirected to a page explaining what happened:
ASP.NET WebForms Blog Post
ASP.NET MVC Blog Post

This example contains two solutions:
The solution for v2010 vol 2.8+ versions - is an ASP.NET WebSite project.
The solution for v2011 vol 1.12+ versions - is an ASP.NET WebApplication project.

Question Comments

Added By: venkat k 4 at: 2/25/2014 10:09:04 PM    

This Code is Use full for me.
But in the user control you use Assemblies. but i didn't find Assemblies in sample
<%@ Register Assembly="DevExpress.Web.v13.1, Version=13.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dx" %>

<dx:ASPxPopupControl >....</dx:ASPxPopupControl >

Please Check Once This Sample.

Thanks & Regards
Venkat

Added By: Pee Jay Cadungog at: 3/24/2014 10:44:26 AM    

hi, how can i call and signout my loginstatus1 in masterpage? i tried adding something like this __doPostBack('MasterPage$LoginStatus1', '');

var updateCountDown = function() {
            var min = Math.floor(_timeLeft / 60);
            var sec = _timeLeft % 60;
            if(sec < 10)
                sec = "0" + sec;

            document.getElementById("CountDownHolder").innerHTML = min + ":" + sec;

            if(_timeLeft > 0) {
                _timeLeft--;
                _countDownTimer = window.setTimeout(updateCountDown, 1000);
            } else {
                window.location = <%=QuotedTimeOutUrl%>;
            }
        };

Added By: GHM Jansen at: 10/7/2014 5:27:00 AM    

Hi,

I'm trying to implement this (very nice) example into my application. All seemed to go well but when I was testing this control in a website I ran into a weird problem. The website has multiple pages but for now I added this control in 2 pages (for testing purposes). There is a base-page from which I open the pages with the usercontrol (no masterpage!). Oke,  I open one page and wait until the timeout message pops up. I press okay and close the page. Then, I open the second page and do the same. Again the popup is shown. I press OK after 20 seconds but I don't close the page, I just wait. After the remaining 40 seconds the application times out nevertheless and jumps to the login page, without the popup showing. Now, I added extra information to the redirect string to find out from which page the timeout is coming and I found out that it was coming from the previous opened page. It looks like that when I open the second page, the usercontrol in the first page is also executed and causes the redirect to the login page.
Is there an explanation for this and consequently, is there a solution?

Thanks,
Geert

Added By: Marion (DevExpress Support) at: 10/7/2014 6:06:03 AM    @GHM Jansen,
We will answer you in the T158466 thread (T158466: Problewm with implementing Code example E3302: How to control state when the Session is being expired and prolong it on demand).Added By: Dr. Wrage at: 5/12/2016 3:09:10 AM    Hi,

loading the "TimeoutPage.aspx" after the session timeout restarts the session or starts a new session. Both is not what I want, so I modified your javascript-code in TimeoutControl.ascx:

...
        var updateCountDown = function() {
            var min = Math.floor(_timeLeft / 60);
            var sec = _timeLeft % 60;
            if(sec < 10)
                sec = "0" + sec;

            document.getElementById("CountDownHolder").innerHTML = min + ":" + sec;

            if(_timeLeft > 0) {
                _timeLeft--;
                _countDownTimer = window.setTimeout(updateCountDown, 1000);
            } else  {
                document.write('<html><head><title>Timeout</title></head><body><h3>Sorry, your Session has expired.</h3></body></html>');
                document.close();
            }            
        };
...

Perhaps this is usefull
Jan



How to create a context menu for field values

How to provide custom menu items to allow SummaryType and SummaryDisplayType runtime selection for a specific Data Field

$
0
0

This example demonstrates how to use the PivotGridControl.PopupMenuShowing Event items to add custom items to the default context menu. This event is handled automatically if you enable the AllowFieldSummaryTypeChanging or  AllowFieldSummaryDisplayTypeChanging attached properties that are defined in the HeaderMenuHelper class. 


See Also:
E2205: How to create a context menu for field values

Question Comments

Added By: rodrigo chamy 1 at: 3/26/2014 5:41:15 PM    

Hi, i need the same functionality but in code behind, it is possible?
i want create fields dynamically from c# code and i need this...

How to restore Auto Filter Row values from an active filter of the GridView after restoring the layout

$
0
0

If you are familiar with our ASPxGridView component, then you might have noticed that, by default, it fills the auto filter row from the filter after restoring the grid's state. Our GridControl component also has this feature, but it is currently undocumented and is disabled by default.

To automatically enable this functionality after restoring the grid's layout, set the static GuessAutoFilterRowValuesFromFilterAfterRestoreLayout property of the GridView object to True.

If you want to enable this feature at runtime on demand, call the GuessAutoFilterRowValuesFromFilter method of the GridView object.


IMPORTANT NOTES
1. Both approaches are currently undocumented, because not all standard scenarios are supported. So, carefully test your application when using the aforementioned APIs to see whether this feature meets your business needs before releasing your app. Don't hesitate to contact us in case of any issues.

2. To use these solutions in an XAF WinForms app, consider the following ViewController:

[C#]
usingSystem;usingDevExpress.XtraGrid;usingDevExpress.ExpressApp;usingDevExpress.XtraGrid.Views.Grid;usingDevExpress.ExpressApp.Win.Editors;namespaceMainDemo.Module.Win{publicclassB152594:ViewController<ListView>{GridListEditorgridlistEditor=null;protectedoverridevoidOnViewControlsCreated(){base.OnViewControlsCreated();gridlistEditor=View.EditorasGridListEditor;if(gridlistEditor!=null){gridlistEditor.Grid.HandleCreated+=Grid_HandleCreated;}}privatevoidGrid_HandleCreated(objectsender,EventArgsargs){GridControlgrid=(GridControl)sender;grid.HandleCreated-=Grid_HandleCreated;using(varcriteriaScope=View.ObjectSpace.CreateParseCriteriaScope()){((GridView)grid.MainView).GuessAutoFilterRowValuesFromFilter();}}}}


See Also:

Filtering via Code
Auto Filter Row

Question Comments

Added By: D. Samsonoff at: 1/30/2014 3:52:09 AM    

GuessAutoFilterRowValuesFromFilter() method does not work in 13.2.6.

DiagramControl - How to create custom shapes with connection points

$
0
0
The Diagram control supports a special language for defining shapes. The main element that contains shape description is ShapeTemplate. This element describes a shape contour and may contain several segments:
- Start. Specifies the start point
- Line. Defines a line with start and end points
- Arc. Defines an arc with start and end points

To specify connection points, use the ShapeTemplate.ConnectionPoints property.
Shapes may contain parameters. Parameters may be used to dynamically calculate an end point, row height and other properties. To specify parameters, use the ShapeTemplate.Parameters property.
To register custom shapes, use the DiagramToolboxRegistrator.RegisterShapes method.
Question Comments

Added By: Piotr Migdalski 1 at: 1/15/2016 7:12:33 AM    

Hello,

Is possible to use in templates images (from resources)?

Added By: Alexander Ch (DevExpress Support) at: 1/18/2016 4:45:20 AM    Hi Piotr,

ShapeTemplates allow you to describe a shape using primitives like Line and Arc. Displaying an image in a shape is a separate feature, which we plan to introduce in future versions.

Thanks,
AlexAdded By: Craig Dunstan at: 4/3/2016 7:05:49 AM    Is there any ability to leverage Visio stencils - either by converting them directly or via an intermediary like SVG?Added By: Alexander Rus (DevExpress Support) at: 4/4/2016 3:00:41 AM    

Hi Craig,
To process your recent post more efficiently, I created a separate ticket on your behalf: T363463: How to use shapes from Visio in DiagramControl

Thanks,
Alexander

Added By: Shuang Xiao at: 5/12/2016 11:16:13 PM    Hi,

Would you please explain further on how to build the xaml like yours? I am wondering this file is created by hand or I can use some funtions to generate the file automatically?
Added By: Alexander Rus (DevExpress Support) at: 5/13/2016 12:41:05 AM    

Hi Shuang,
I've created a separate ticket on your behalf (T378595: Is there a tool to generate shape descriptions for DiagramControl ). It has been placed in our processing queue and will be answered shortly.

Thanks,
Alexander


How to display a non-persistent object's Detail View from the Navigation

$
0
0

This example is applicable to XAF versions prior to 16.1. In 16.1, we significantly simplified the use of non-persistent objects. For details, refer to the  How to: Display a Non-Persistent Object's Detail View from the Navigation help topic.

Question Comments

Added By: DKx at: 7/1/2015 7:27:56 AM    

This code fails with session-based non-persistent classes when Refresh action is called:

"The error occurred:
Type:       SessionMixingException
Message:    The 'Example.Module.MyNonPersistentObject' object belongs to a different session."

void application_CustomProcessShortcut(object sender, CustomProcessShortcutEventArgs e)
{
   if (e.Shortcut.ViewId == "MyNonPersistentObject_DetailView")
   {
       IObjectSpace objectSpace = Application.CreateObjectSpace();
       e.View = Application.CreateDetailView(objectSpace, objectSpace.CreateObject<MyNonPersistentObject>(), true);
       e.Handled = true;
   }
}

How to solve it?

Added By: Dennis (DevExpress Support) at: 7/1/2015 11:26:44 AM    @DKx: It is wrong to inherit non-persistent classes from the base XPO classes like BaseObject, XPObject, etc. Use session-less POCOs instead (like demonstrated in this example).Added By: DKx at: 7/2/2015 12:52:10 AM    

@Denis: Yes, you're right.

A possible solution I found as working is to pass ObjectSpace instead of Session to created non-persistent object. This way I can use session functions inside as usual (FindObject etc.):

abstract public class NonPersistentObject
{
   private IObjectSpace ObjectSpace;

   public NonPersistentObject(IObjectSpace ObjectSpace)
   {
       if (ObjectSpace == null)
           throw new Exception("Unintialized ObjectSpace for non-persistent object passed.");

       this.ObjectSpace = ObjectSpace;
   }
   
   protected Session Session
   {
       get { return ((XPObjectSpace)ObjectSpace).Session; }
   }
}

Added By: Michael (DevExpress Support) at: 7/2/2015 5:19:34 AM    @DKx: Your solution is correct.Added By: Willem de Vries at: 7/2/2015 12:06:17 PM    

When you develop something like this, but need an editable detailview, change AllowEdit to true, and add the following line:
((DetailView)e.View).ViewEditMode = ViewEditMode.Edit;
This will put the detailview immediately in edit mode.
This isn't an issue when using domain components, but when you use nonpersistent classes derived from an XPO object, it comes in handy, because changing from view to edit mode forces a refresh, with an sessionmixing error as a result.

Added By: Willem de Vries at: 7/2/2015 12:08:30 PM    

@Dennis: using nonpersistent objects gives us great power when using OnChanged() etc. And it frees us from studying the DC world.

Added By: Michael (DevExpress Support) at: 7/3/2015 2:42:43 AM    @Willem: Non-persistent classes derived from base XPO classes won't work correctly with built-in controllers. They cannot be refreshed because they are not read from the database. If you need property change notifications, implement the INotifyPropertyChanged interface in the POCO class.

How to suppress the save confirmation dialog when closing a DetailView for a new object left untouched by an end-user

$
0
0

Scenario
This example demonstrates how to implement the following behavior (which is default in Microsoft Outlook) in XAF Windows Forms applications:

- A user can create a new record, and when its detail form is opened he or she may close the form without entering any data (e.g., a new record was created by accident). In this case, the form can be closed without any save confirmation, because no user data needs to be saved.

- If a user enters some data into the form and then closes it, the save confirmation appears as expected not to lose entered data.

 

To implement it
Copy the WinSolution.Module.Win\SuppressConfirmationForNewObjectsDetailViewController.xx file into YourSolutionName.Module.Win project.


To test it
You can also run functional tests from the E2114.EasyTests\E2114.ets folder.

See Also:
WinModificationsController Class
ModificationsController.ModificationsHandlingMode
Core - Disable the confirmation dialog when closing a form with a new object left untouched

Question Comments

Added By: rushdan . at: 12/4/2014 2:08:46 AM    

I have see example . That is great.
So I would like to ask, is it possible to apply for Web ?

Thanks

Added By: Dennis (DevExpress Support) at: 12/4/2014 2:40:43 AM    @rushdan: This solution cannot be applied to the Web version because there are no such confirmation dialogs there by default.Added By: Paul Kubb at: 3/31/2016 9:04:33 PM    Just a little comment that I think this feature should be out-of-the-box.
Popping out this message every time even nothing touched is annoying and I don't think anybody will like it.Added By: Dennis (DevExpress Support) at: 4/1/2016 2:19:57 AM    @Paul: Our team will take your feedback into account, thanks.Added By: Alexandre Miller at: 4/1/2016 4:22:05 AM    I totally agree with Paul.
@Dennis Please +1 :) Added By: Dennis (DevExpress Support) at: 4/1/2016 6:10:00 AM    OK, thanks

How to represent an enumeration property via a drop-down box with check boxes

$
0
0

Scenario:

There is an enumeration type decorated with the FlagsAttribute, which means that an enumeration can be treated as a set of flags. There is also a property of this enumeration type inside the business class. This is helpful when several predefined enumeration values can be stored using this data property. In the UI, this data property is usually represented via an editor with multiple check boxes:


Steps To Implement:

Since there is no standard  PropertyEditor for enumerations that would allow you to store several values at once, it is common to implement custom Property Editors for this task. A custom PropertyEditor will take data property value as its input and represent it in the UI using a custom visual control. There will be one PropertyEditor for WinForms (based on the CheckedComboBoxEdit control from the XtraEditors Suite) and one for ASP.NET (based on the ASPxGridLookup control from our ASPxGridView and Editors Suite), because there is no platform-agnostic way to achieve such a look and feel.


Consider following the steps below to implement and use editors from this example in your project.
1. Implement an enumeration type decorated with the FlagsAttribute as shown in the E689.Module\BusinessObjects\DemoObjects.xx file;
2. Copy the E689.Module.Win\Editors\EnumPropertyEditorEx.xx file into YourSolutionName.Module.Win project;
3. Copy the E689.Module.Web\Editors\ASPxEnumPropertyEditorEx.xx file into YourSolutionName.Module.Web project;
4. Build the solution and invoke the Model Editor for the ModelDesignedDiffs.xafml files from YourSolutionName.Module.Win and YourSolutionName.Module.Web projects.

5. Locate the BOModel | YourClassName | Members | YourEnumerationProperty node and set its PropertyEditorType property to the corresponding EnumPropertyEditorEx types.

 

See Also:

Implement Custom Property Editors
How to represent a enumeration property via radio buttons or check boxes on the Web

Question Comments

Added By: Pawel Botwina at: 7/6/2013 1:11:36 AM    

Hello,

How can I filter by flags enum property in the server mode? I mean filtering the ListView by AutoFilterRow.

Added By: Alex Kads at: 4/4/2014 2:35:40 PM    

would that same code for WEB

Added By: Dennis (DevExpress Support) at: 4/8/2014 12:45:41 AM    

@Alex: While we do not have a ready Web version of this example, you may find the code from the E1807 example helpful. Thanks.

Added By: Anatol (DevExpress Support) at: 4/9/2014 9:32:02 AM    

Web version is added.

Added By: Leong Vai Long at: 5/14/2014 3:22:04 AM    

Hi, I had try this method for the XAF web version. The question is how i want to use the XAF Display Name to show in the lookup? bcos I only see the enum values.
Thanks.

Added By: Dennis (DevExpress Support) at: 5/14/2014 9:09:47 AM    

@Leong: This particular functionality is not implemented in this example solution. You would need to modify the E689.Module.Web.Editors.EnumPropertyEditorEx class to achieve this. While we do not have a ready sample, feel free to contact our ASP.NET team on how to implement your task with the ASPxGridLookup component used in this example. Once you receive a solution for this component, it can be easily integrated in XAF.

Added By: Leong Vai Long at: 5/14/2014 10:46:46 PM    

Hi Dennis,

1. Is it possible to change the ASPXGridLookup with the ASPXDropDownEdit? This is the link http://blog.zerosharp.com/three-ways-to-store-a-list-of-currency-codes-in-xaf/#disqus_thread, but this example use the string, how to convert it to enum?
2. How to contact your ASP.NET team to implement my task with the ASPXGridLookup?

Thanks.

Added By: Dennis (DevExpress Support) at: 5/15/2014 7:07:00 AM    

@Leong:

A1: Sure, you are free to implement your own custom PropertyEditor based on any control you want.
A2: You can submit a new question through https://www.devexpress.com/Support/Center/Question/Create and specify the ASP.NET Web Forms platform and ASPxGridView and Editors Suite as a product. In the new ticket describe what you have implemented so far, attach a small non-XAF sample where you tried to customize the ASPxDropDownEdit control and also describe your requirements in detail. Before doing this, you may want to check out the documentation on our ASP.NET Web Forms controls and also corresponding demos. To effectively search our knowledge base, documentation and examples, you may find our Search Engine helpful.

 

Added By: Dennis (DevExpress Support) at: 5/19/2014 6:56:03 AM    

@Leong:

I have modified the Web version of this custom editor to support localized values. Please refer to the attachment.

Added By: MohammedFarooq at: 5/16/2016 7:28:54 AM    Hi Dennis,

How can i read the Text value that is displayed in the editor? Added By: Dennis (DevExpress Support) at: 5/16/2016 7:56:25 AM    

@MohammedFarooq: There are different properties like EditValue/Text/Value in underlying WinForms and ASP.NET controls. Would you please elaborate a bit more on how you are going to reuse these display values (please submit a separate ticket via the https://www.devexpress.com/Support/Center/Question/Create service for that purpose)?

How to create a PropertyEditor based on the XtraRichEdit control

$
0
0

Take special note that this editor is intended to be used for a simple and most common scenario when only one text property in a Detail View is edited with the help of the XtraRichEdit control (RichEditControl). Other scenarios are not supported in this example and are required to be implemented manually. For example, if there are more than one property, edited with this editor in a Detail View, then there may be problems with merging in ribbons. See the B142856 issue for more detailed information.

Important Notes
1.
 Please take special note that this example is not a complete solution and is supposed to be further tested and modified by you according to your business requirements.

2. The standard XAF Save Action may be activated on the first load in this example, because the MS Word and XtraRichEdit RTF formats are different and thus the object receives a different value on the first value post. Once you save the value in the control's format, it will work as expected. See also the Problem with setting the RtfText in XtraRichEdit and ImmediatePostData with XtraRichEdit tickets for the details on how to improve tracking of changed values in the RichEditControl component.

 

See Also:
Implement Custom Property Editors
How to: Implement a Property Editor for Windows Forms Applications
XtraRichEdit Home
PropertyEditors - Support the XtraRichEdit control.

Question Comments

Added By: Willem de Vries at: 10/24/2012 7:25:46 AM    

After copying the necessary files to my project, i ran into an error in MergeRibbonDetailViewController. I changed the code slightly (in the test):

        private void Frame_TemplateChanged(object sender, EventArgs e) {
            UnMergeRibbon();
            mainRibbonControl = null;
            IClassicToRibbonTransformerHolder form = Frame.Template as IClassicToRibbonTransformerHolder;
            if (form != null && form.RibbonTransformer != null) {
                form.RibbonTransformer.Transformed += RibbonTransformer_Transformed;
            }
        }

Added By: Jerome Pech at: 5/16/2016 12:15:32 PM    Merging the Ribbon does not work if UseOldTemplated = false; is set. 
[C#]
return((XtraFormTemplateBase)(Application.MainWindow.Template)).Ribbon;
causes an error, that DetailFormRibbonV2 can not be converted to XtraFormTemplateBase.

Can you please provide an example how to merge ribbons with the new Ribbon V2 (using 15.2)?











Generating Table Of Contents (TOC): Practical Guide

$
0
0

This example illustrates the simplest approaches to generate a TOC for a given source document.

Lets imagine that you have obtained a document and you need to generate a TOC for this document. Here are the steps you need to execute for this purpose:

1) Decide which parts for the document should be TOC entries.
This step is specific to your document. For instance, this document might contain several headings in the following form: "Chapter NoXY". Generally, you can use Search API (see the Using the Search and Replace API functionality and Search API - An example of use examples) to find the position of these parts in the document. In this particular example, we search for TOC entries (see the SearchForTOCEntries() method) by examining the font size of the paragraphs. This approach is based on the How to list fonts that are used in a document code example.

2) Mark TOC entries in a special manner.
This step is required because the TOC field, which will be added in the next step, should be able to recognize document parts as a TOC entries when this field is updated (see Fields to learn more). We can use the following simple approaches:

- Paragraph styles with set outline levels
You need to create and apply ParagraphStyles with specific ParagraphPropertiesBase.OutlineLevel Property values. Take a moment to look at the How to create and apply document styles code example to learn more about Styles API.

- Outline levels
Simply apply specific outline levels to paragraphs considered TOC entries

- TC fields
Insert TC fields in the document. We have a code example that illustrates how to insert fields in code: How to create nested fields programmatically

3) Add a TOC field to the document and update this field (see the InsertTOC() method).
A TOC field should have switches that correspond to the method in which TOC entries are marked in the previous step.

Here is a screenshot that illustrates the operation of a sample application:

Take a moment to look at the Rachel Reese - DevExpress Scheduler & RichEdit Blog and related webinar to learn the basics of the TOC feature.

Question Comments

Added By: Genesis Supsup at: 5/16/2016 8:17:23 PM    Is this feature working in the ASP.Net compoenent?

Custom GridControl - How to hide particular GroupRow Headers & Footers

$
0
0

This example demonstrates how to implement a GridControl descendant which allows hiding the header and footer for groups with an empty group row value.

Question Comments

Added By: Guo Clark at: 5/16/2016 9:47:35 PM    I have a question is how to avoid VisibleIndexes insert duplicate values, because I found this place to be a mistaken example, when performing ExpandRow () method will insert duplicate values in VisibleIndexes, thank you! 

How to implement the Master-Details functionality (DataTable is a DataSource)

$
0
0

DataRow does not have a property that includes all child rows. To get child data, implement a multi binding converter that will filter the child data table based on the master row id.


How to scroll TableView on selecting row with moving the mouse outside view bounds

$
0
0

Obsolete. Starting with 12.1, to achieve this functionality, set the GridControl.SelectionMode property to Cell. 




This example illustrates how to add the DXGrid behavior which provides the capability to select rows and cells by simply moving the mouse over them with the mouse button pressed and auto-scrolling the view in a necessary direction.

This functionality was implemented via attached behavior for DXGrid which encapsulates all the selection functionality.

The scrolling functionality was implemented in a separate class named ScrollController.

Question Comments

Added By: MichaelDaly at: 10/15/2012 5:51:50 AM    

This example needs more testing.

Line 207: rightColumnWhenUnselect can be null, need to insert this before: if (rightColumnWhenUnselect == null) rightColumnWhenUnselect = View.VisibleColumns.Last();

Line 181: CurrentSelectionInfo.Column can be null

It's a good effort, but the scrolling does not feel as smooth as in other apps, e.g. Excel

Added By: MichaelDaly at: 10/15/2012 5:53:21 AM    

Note: previous comment was for code in GridSelectingBehaviour.cs

Added By: Andrey K (DevExpress Support) at: 5/7/2015 10:19:21 AM    Hello,

It seems that your message was lost in our Support Center. Thank you for your remarks. We will improve our example accordingly.

Thanks,
Andrey

(Obsolete) How to display a login view as a popup window during navigation between views

$
0
0

Starting with 14.2, please use this example.
This approach can be applied starting with 13.2.9. 

This example demonstrates how to check whether the user is logged in and display a login view when it is necessary during navigation.

It is necessary to perform the following steps to accomplish this task:

1. Add a new view and place a dxPopup in it.

2. Implement the required logic for this view in a corresponding view model.

3. Handle the HtmlApplication.initialized event. In this event handler, get the login view template using the HtmlApplication.getViewTemplate method and add the view to the view port. This will allow you to display its internal popup using options from its view model.

4. Bind the login view model to the view markup using Knockout.

5. Declare a global variable for determining when a user is logged in. In this example we set this option to false by default, and we will set it to true when a user is logged in. This variable can be accessed from any part of the application and we can change its value in the login view model.

6. Handle the HtmlApplication.navigating event. In this event handler, we can get a view info (see HtmlApplication.getViewTemplateInfo) for the navigated view and check user credentials if necessary. For this purpose, we added the secure option to those views that should not be displayed for unauthorized users. If the user unauthorized, we can call a method from the login view model to display dxPopup from the login view. Moreover, you can cancel navigation by setting the cancel parameter of the event handler to true.

See also:
How to send authenticated requests to the OData service

Question Comments

Added By: Alexandre Henriques at: 4/28/2014 7:36:44 AM    

How do I make this piece of code in version 13.2.7?

app.initialized.add(function() {
       var $view = app.getViewTemplate("LogOnPopup");
       $view.appendTo(".dx-viewport");
       LogOnAsPopupView.loggedOn = ko.observable(false);
       LogOnAsPopupView.logOnPopupViewModel = LogOnAsPopupView.LogOnPopup();
       ko.applyBindings(LogOnAsPopupView.logOnPopupViewModel, $view[0]);
   });

Added By: Nikolai (DevExpress Support) at: 4/28/2014 11:00:20 PM    Hi Alexandre,

I have created a separate ticket for this issue. Please post comments to the How to display a login view as a popup window during navigation between views (13.2.7) ticket.Added By: Faraz Faheem at: 6/1/2014 3:28:54 AM    

Im having error on initialized event. Error says 'Error: cannot ready property 'add' of undefined' on app.initialized.add(funtion() { line.

Please help me

Added By: Faraz Faheem at: 6/1/2014 3:52:38 AM    

I just upgraded my project to 13.2.9 by project converter and viola everything works.

Thanks for the self-explanatory post.

Added By: Nikolai (DevExpress Support) at: 6/2/2014 12:15:33 AM    You are always welcome, Faraz.Added By: Faraz Faheem at: 6/3/2014 7:56:19 AM    

Hi Nikolai,

With authentication implementation, my LogOn.js file looks like below
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
AESalesApp.LogOnPopup = function (params) {

   var viewModel = {
       userid: ko.observable(""),
       password: ko.observable(""),
       visible: ko.observable(false),
       authenticated: ko.observable(false),
       redirectParam: this.redirectParams,
       logOn: function () {

           var user = {
               Name: this.userid(),
               UserName: this.userid()
           };
        
           AESalesApp.UserDb.authenticateUser(user).done(function (data) {

               AESalesApp.loggedOn(true);

               AESalesApp.credentialStore.insert({
                id: 1,
                accessToken: "34234234234234234",
                expiry: 234,
                refreshToken: "134234234234234",
                name: "faraz"
                });

               if (viewModel.redirectParam) {
                   AESalesApp.app.navigate(viewModel.redirectParam.uri, viewModel.redirectParam.options);
               }
               viewModel.close();

           });
       
       },
       show: function (redirectParams) {
           viewModel.visible(true);
           viewModel.redirectParam = redirectParams;
       },
       close: function () {
           viewModel.visible(false);
           delete viewModel.redirectParam;
       }
   };

   return viewModel;
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
where:
AESalesApp.UserDb is CustomStore getting data from Web Api. It is working fine and data is coming back from authenticalUser call.

I am having 2 problems here.
1. Done function param 'data' is not getting results from authenticateUser function  
2. Popup is not closing down

Added By: Nikolai (DevExpress Support) at: 6/4/2014 2:40:03 AM    Hi Faraz,

I have created a separate ticket for this issue. Please post all comments in the How to implement authentication with a popup login viewAdded By: Jerther at: 11/28/2014 2:08:30 PM    

this line should be updated:

<div data-bind="dxTextBox:{ type: 'password', value: password }"></div>

with

<div data-bind="dxTextBox:{ mode: 'password', value: password }"></div>

Added By: Nikolai (DevExpress Support) at: 12/1/2014 3:52:34 AM    Hi Jerther,

Thank you for bringing this to our attention. I've updated this example.Added By: V.Mangione at: 12/4/2014 7:55:59 AM    

Hi, this sample doesn't appear to be working anymore on just released v 14.2.3
The popup stays hidden.

Added By: Nikolai (DevExpress Support) at: 12/5/2014 2:23:56 AM    Hi,

Starting with 14.2, please use this example.Added By: IMiron at: 10/9/2015 2:06:22 PM    

Hi,

Can you please tell me how this can be accomplished with the Angular approach?
A sample would be best.

Thanks,
Ionut.

Added By: Nikolai (DevExpress Support) at: 10/12/2015 1:38:07 AM    Hello IMiron,

The DevExtreme framework is based on KnockoutJS and jQuery. AngularJS has its own navigation mechanism. I suggest that you refer to Angular documentation and forums regarding this issue.

See also:
ngView
Routing & Multiple ViewsAdded By: Julian Leung at: 4/6/2016 9:07:30 PM    I am using this login sample, but I got some problems when I change the dxList to dxDataGrid. I seems that the problem come from data source, it cannot get the data from it.

        <div data-bind="dxDataGrid: { dataSource: dataSource,                 columns: [                    { dataField: 'ItemCode'},                    { dataField: 'BatchNum'},                      ] 

                  }">


var dataSource = {    store: new DevExpress.data.CustomStore({        load: function () {            return $.getJSON('http://localhost:55960/DataService.svc/efSeason');        }    })}


Added By: Nikolai (DevExpress Support) at: 4/7/2016 3:55:00 AM    

Hello Julian,

To process your recent post more efficiently, I created a separate ticket on your behalf: T365094: dxDataGrid - Ho to implement a custom data source. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

How to embed a Document Preview for WPF into the End-User Report Designer for Windows Forms

Data Source Wizard – How to Replace the Standard Query Builder

$
0
0

 This example demonstrates how to replace the Query Builder dialog available through the query configuration page of the Data Source wizard with a custom dialog. To achieve this, create a custom wizard page that inherits from the default query configuration page class (DevExpress.DataAccess.Wizard.Presenters.ConfigureQueryPage). In the page class, override the RunQueryBuilder method with your custom logic to display a custom query builder and receive the resulting query.

 Implement the IWizardCustomizationService interface to register a custom query configuration page.

 For a general code example of how to customize the Data Source Wizard using the IWizardCustomizationService interface, see How to customize the New Report Wizard (introduced in the 2014 vol.1 release) in the End-User Designer.

 To display the created custom query customization page instead of the default Query Editor dialog when editing an existing query, implement the ISqlEditorsCustomizationService interface.

How to make a ListBoxControl's vertical scrollbar always visible

$
0
0

This example illustrates how to make a ListBoxControl's vertical scrollbar always visible

Question Comments

Added By: Travis at: 5/19/2016 6:35:46 AM    Thanks for the instruction, but unfortunately this approach doesn't work for WPF controls (DX.15.1).Added By: Nadezhda (DevExpress Support) at: 5/19/2016 6:48:11 AM    

Hello Travis,

Yes, you are right. This example demonstrates the approach for the WinForms ListBoxControl. To investigate possible solutions for the WPF platform, I have created a ticket on your behalf: How to make the WPF ListBoxEdit's vertical scrollbar always visible

It has been placed in our processing queue and will be answered shortly.

Viewing all 7205 articles
Browse latest View live