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

How to use the MultiSelect mode in the LookUpEdit

$
0
0

We have implemented the MultiSelect mode in the LookUpEdit as an extension. To use it, you will need to add a reference to the DevExpress.Xpf.Grid.Extensions library and assign MultiSelectLookUpEditStyleSettings to the LookUpEdit StyleSettings property. If you wish to select records on a click basis (without the CTRL modifier), customize the editor's PopupContentTemplate and use the OneClickSelectionView as a GridControl view. Please note that the LookUpEdit does not support text editing in the MultiSelect mode.

Question Comments

Added By: Adel Ayyam at: 1/6/2014 2:50:47 PM    

Hi Devexpress,
The example is not working as expected when IsTextEditable="True", when searching by some text and selecting corresponding items the selecteditems is always empty ???

Best regards,
Ayyam

Added By: Alexander Ch (DevExpress Support) at: 1/7/2014 4:28:02 AM    

Hi Ayyam,

I've created a separate ticket regarding this issue: http://www.devexpress.com/Support/Center/Question/Details/Q465097. We will process your inquiry there.

Thanks,
Alex

Added By: Stefan N at: 2/7/2014 5:46:08 AM    

This does not work or I do not complete understand it. How do I get the selected items out of it? Can I use the SelectedItem property with a binding? I've tried it but only one item is set, not a list of items if I select more than one.

Added By: Alexander Ch (DevExpress Support) at: 2/7/2014 7:01:14 AM    

Hi Stefan,

I suggest that you use the LookUpEdit.EditValue property to get or set selected items.

Thanks,
Alex

Added By: Stefan N at: 2/7/2014 8:06:11 AM    

Thanks Alex. It works with the EditValue property.

Maybe you can help me with one additional problem in this context:
I add a delete button to the LookUpEdit.Buttons property. I am not sure, what I should do in the event handler to delete the selection. Currently I am setting the EditValue to Null, which updates the bounded datasource correctly. But when I reopen the editor, the items are still selected.

Added By: Andrey Kunitsyn (DevExpress Support) at: 10/31/2014 6:29:24 AM    
Hello Stefan,

We accidentally discovered that your initial post was out of scope of our Support Center for a long time. Please accept our sincere apologies for not responding in a timely manner.


I've created a separate ticket on your behalf regarding the task you've mentioned in your message to process it more efficiently: LookUpEdit - Selected items are not cleared when EditValue is set to Null  

If this task is still important for you, please find a couple of minutes to refer to that thread.


Thanks,
Andrey

How to create new Dashboard add a Grid Item to it and bind it to data in code

How to customize a dashboard layout

$
0
0

The following example demonstrates how to customize a dashboard layout in code.


In this example, the DashboardViewer loads an existing dashboard with the predefined layout form an XML file. The dashboard contains three dashboard items that are placed horizontally side-by-side.

The following steps are performed to create a new layout:

- Three layout items are created to display the existing dashboard items. The weight parameter specifies the layout item size.

- A new layout group is created to display the Grid and Chart dashboard items. The orientation parameter specifies the orientation of layout items within this group.

- A root layout group is created. This group contains the previously created group and the layout item displaying the Range Filter dashboard item.

- The root layout group is assigned to the Dashboard.LayoutRoot property.

See Also:
How to create new Dashboard add a Grid Item to it and bind it to data in code

How to hide particular rows and columns

$
0
0

The following example demonstrates how to hide particular rows and columns by handling the CustomFieldValueCells Event.

In this example, the event handler iterates through all row headers and removes rows that correspond to the "Employee B" field value, and that are not Total Rows.

How to use XPO in ASP.NET MVC3 application (Razor)

$
0
0

This example demonstrating a simple ASP.NET MVC3 application using XPO as Data Access Layer.

See also: How to use XPO in an ASP.NET MVC application

Question Comments

Added By: TPS Programmer at: 11/3/2014 2:38:52 AM    

how to convert this syntaks

@model IEnumerable<CustomerViewModel>
@Html.Partial("IndexPartial", Model);

into vb syntax ?

Added By: TPS Programmer at: 11/3/2014 2:40:10 AM    

almost forget, because in VB source code, index.cshtml still in C#, not in VBHTML

Added By: Anthony (DevExpress Support) at: 11/3/2014 5:01:27 AM    

Hi,

The code would be as follows:

[VB.NET]
@ModelType IEnumerable<CustomerViewModel> @Html.Partial("IndexPartial", Model)

As for the example, we will correct the syntax as soon as possible.

How to measure loading time on the server and client sides

$
0
0
This example illustrates two approaches:

1. How to measure and display loading time on the sever using the System.Diagnostics.Stopwatch class:
CS:
[C#]
Stopwatchsw=System.Diagnostics.Stopwatch.StartNew();//some operationssw.Stop();AddEventLog(String.Format("Page_Load, Time: {0}",sw.Elapsed.TotalMilliseconds));privatevoidAddEventLog(stringeventLog){if(!String.IsNullOrEmpty(eventOrder))eventOrder+="<br/>";eventOrder+=eventLog;}
VB:
[VB.NET]
....Private sw As Stopwatch = System.Diagnostics.Stopwatch.StartNew()'some operations sw.Stop() AddEventLog(String.Format("Page_Load, Time: {0}", sw.Elapsed.TotalMilliseconds)) ...PrivateSub AddEventLog(ByVal eventLog AsString)If (NotString.IsNullOrEmpty(eventOrder)) Then eventOrder &= "<br/>"EndIf eventOrder += eventLogEndSub

All results are passed to the client-side for demonstration purposes.

2. How to measure rendering time on the client using JavaScript methods: 
     1) On the first page load create a Date variable in the head section.  
     2) Handle the ASPxClientGlobalEvents.ControlsInitialized event raised after our controls were loaded to check time difference. 
     3) I've overridden our internal aspxCallback function which is executed after the new result is applied from the client to define a start point on callbacks.

[JScript]
var start = new Date();function ge_ControlsInitialized(s, e){if(e.isCallback == false){var original = aspxCallback; aspxCallback = function(result, context){ start = new Date(); original(result, context);}}var end = new Date();var output = document.getElementById("output"); output.innerHTML = "Loading time(in ms): " + (end - start);}

How to create a master-detail report using a Subreport

$
0
0

The Master-Detail Report article in the XtraReports documentation describes how to create master-detail reports in two ways - via the DetailReportBand and XRSubreport controls. The first approach is preferable and can be easily used in XAF. However, if you need to use the second approach, steps required to implement it in XAF should be slightly modified, because generally the class on the Many side of an association does not have a simple property with the master's ID. You can filter a detail report by the master object's ID:

[C#]
usingDevExpress.ExpressApp.Reports;privatevoidsubreport1_BeforePrint(objectsender,System.Drawing.Printing.PrintEventArgse){XRSubreportsubreport=(XRSubreport)sender;subreport.ReportSource.Parameters["MasterID"].Value=((XafReport)xafReport1).ObjectSpace.GetKeyValue(GetCurrentRow());}

For additional information, please see reports in the attached example.

Note, this example is now included as a part of the FeatureCenter demo.

IMPORTANT NOTES
If you use the ViewDataSource (from the ReportsV2 module) for the master report, then you will have to modify your script as follows:

[C#]
usingDevExpress.Xpo;privatevoidsubreport2_BeforePrint(objectsender,System.Drawing.Printing.PrintEventArgse){XRSubreportsubreport=(XRSubreport)sender;subreport.ReportSource.Parameters["MasterID"].Value=((ViewRecord)GetCurrentRow())["Oid"];}
Question Comments

Added By: zhan gao at: 5/23/2012 12:11:04 AM    

The example dosen't support 11.2?

Added By: Anatol (DevExpress Support) at: 6/5/2012 4:17:31 AM    

The example was updated and now works fine with version 11.2.

Added By: Willem de Vries at: 10/24/2012 8:22:38 AM    

Thank you for providing this example.
Whilst the first approach may be preferable for simple reports, i find this example indispensable for creating reports with detail-reports anywhere in the report. The first approach does not give the possibility to continue the master report after the details (e.g. for a section where a customer can sign the contract).

Added By: Raoulw at: 1/22/2013 12:01:25 PM    

Looks like this is broken/Changed for 12.2. I have to change existing subreports based on this sample to set Request Parameters to False, because after updating the dialog shows up. Even if I do that, the Parameters Dialog is shwoing...

Added By: Anatol (DevExpress Support) at: 4/2/2013 7:28:52 AM    

It is required to make the parameter invisible to hide the parameters panel. I apologize for missing this step. I have updated the example.

Added By: Paolo Parente at: 1/31/2014 12:46:25 AM    

Hi, this example doesn't works for me. Maybe the problem should be that the ID type is GUID? What type the parameter should be if the ID type is GUID? Thanks, Paolo

Added By: Alexander Dračka at: 11/4/2014 5:58:41 AM    

I'm currently dealing with the very same issue. What a system type should be used to make Guid applicable in this scenario?

How to show custom popup context menu items only for certain fields

$
0
0

This is an extended version of the How to add a custom popup menu item example. It demonstrates how to hide certain context menu items using the client-side ASPxClientMenuBase.PopUp and ASPxClientMenuBase.CloseUp events. It is possible to use the ASPxPivotGrid.JSProperties dictionary to pass additional information for client side processing.

Question Comments

Added By: Ananda Krishna 1 at: 7/18/2012 2:22:15 AM    

How to implement same when we click the field name in the area, say, coulmn or data area?


How to add a CheckBox column which provides to check/uncheck all CheckBoxes in this column

$
0
0
This example demonstrates how to add a CheckBox column which allows you to check/uncheck all CheckBoxes in this column.
To do this, we add a CheckEdit to the current column's header and bind its IsChecked property to the attached property. Then, we subscribe to the GridColumn's Loaded event. When Loaded is raised, we iterate through all items in the ItemSource and subscribe to its PropertyChanged event. Also, we iterate through all cells in the current column. If the cell value equal true, we increase the total count of true values. After that, we subscribe to the ItemSource collection's CollectionChanged event. When IsChecked is changed, we iterate through all cells of the column and set its value to the IsChecked value. When CollectionChanged is raised, we calculate which item was added/deleted and subscribe/unsubscribe to its PropertyChanged event. Then, we calculate to what value CheckEdit must be set. When PropertyChanged is raised, we increase/decrease the total count of true values and also determine to what value CheckEdi must be set.

How to add a custom button into LookupPropertyEditor to edit the currently selected record

$
0
0

You can open the detail form for the currently selected object if you press Ctrl+Shift while clicking the editor. Another way is to implement your own editor, derived from the DevExpress.ExpressApp.Win.Editors.LookupPropertyEditor, which will provide a specific functionality you need.
Fact is that the LookupPropertyEditor is represented in a detail view by the LookUpEdit control, which allows various customizations. So, you can customize it by adding a special button that will invoke a Detail View for the selected object or even allow your users to create new records directly.



See Also:

How to work with referenced properties via a simple drop down list instead of the standard LookupPropertyEditor (Example)

How to implement columns filtering in the Column Chooser

$
0
0

This example demonstrates how to implement a custom Customization Form with the TextEdit placed on it, to filter the columns list.

Question Comments

Added By: Faith Clayton at: 11/5/2014 10:36:43 AM    

This code appears to have a bug. Sometimes, when I move a column to the grid (ex. move the top column to the grid), I can no longer scroll properly. The scroll bar jumps back up to its original position.

Added By: Alexey Z (DevExpress Support) at: 11/5/2014 11:00:40 PM    

Hello,

In order not to mix several questions within one thread, I will extract your question to a new ticket. Let us continue our discussion there E1787 - cannot use scrollbar in a specific scenario.

How to: Use the PropertyGrid to Manage Collection Properties

$
0
0

This example shows how to manage collection properties and implement item initializers in the Property Grid.

Question Comments

Added By: Andrew Roberts 5 at: 11/5/2014 3:02:37 PM    

I am trying to use this example but the ItemInitializer class needs to be in a ViewModel and the dxprg:CollectionDefinition is part of a DataTemplate in a separate file. I can't use NewItemInitializer as suggested in this sample.

Tried:
NewItemInitializer="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=DataContext.ItemInitializer}"

Received error:
System.Windows.Data Error: 40 : BindingExpression path error: 'ItemInitializer' property not found on 'object' ''WorkstationsEditorViewModel' (HashCode=43595579)'. BindingExpression:Path=DataContext.ItemInitializer; DataItem='WorkstationsEditorView' (Name='workstationsEditorView'); target element is 'CollectionDefinition' (Name=''); target property is 'NewItemInitializer' (type 'IInstanceInitializer')

So it’s looking for a property on WorkstationsEditorViewModel

So I did this on the ViewModel:

public ItemInitializer ItemInitializer {
           get { return new ItemInitializer();}

Now not throwing errors, but I'm not getting the Collection property showing in the Property Grid

Added By: Andrey Kunitsyn (DevExpress Support) at: 11/5/2014 11:41:05 PM    


Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T169706: Example E4855 - Moving ItemInitialized to the View Model raises a binding exception. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Thanks,
Andrey

How the splitter's position can be saved on exit, and restored when the application is next launched

$
0
0

This example demonstrates how to save and restore a Splitter position by utilizing Serialization technology.
For more information, please refer to the How the splitter's position can be saved on exit and restored when the application is launched next time Knowledge Base article.

See Also:
BinaryFormatter Class
FormatterAssemblyStyle Enumeration
SplitContainerControl Class

Question Comments

Added By: Vernon Robinson at: 11/5/2014 5:19:25 PM    

Tried running this example.  After converting to 14.1 and changing the Target Framework to Version 4.51, the application starts, but the Splitter is missing and the buttons perform no action.  Any idea on how I can get this or some other method to work to save the position of the splitter based upon actions by the User.

Added By: Yaroslav (DevExpress Support) at: 11/6/2014 12:21:55 AM    

Hi Vernon,
I've just tested the VB.NET version of this example under .NET Framework 4.5.1 (DevExpress 14.1.7), but noticed no issues. Would you please provide us with your own version of this solution so we can try to reproduce this issue using it? I would also appreciate a short screencast illustrating the described problem (you can use the Jing tool to create it).
We're looking forward to your reply.

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

$
0
0

Scenario

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

Steps to implement

1. Add a new business class to your platform-agnostic module, and override its AfterConstruction method, as shown in the Solution2.Module\BusinessObjects\DomainObject1.xx file;

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 than the How to generate and assign a sequential number for a business object within a database transaction, while being a part of a successful saving process (XAF) example, it is pretty safe and should also work in the most typical business scenarios (except for the middle-tier Application Server scenario, because the Session.DataLayer property is not initialized in this case).

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

Question Comments

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

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

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

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

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

Hi,

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

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

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

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

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

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

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

Hallo

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

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

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

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

How to customize the settings of a toolbar item created for an Action.

$
0
0

See the How to: Customize Controls Associated with an Action for more details.

See Also:
E1977

Question Comments

Added By: Mario Blatarić at: 9/17/2013 4:01:09 AM    

Could you provide an example of how to do the same thing on Web? Web version of http://documentation.devexpress.com/#Xaf/CustomDocument3183 documentation article would also be helpful.

Added By: Dennis (DevExpress Support) at: 10/23/2013 4:20:20 AM    

Thanks for your suggestion, Mario. We will consider creating a Web version in the future.


LINQ to XPO

$
0
0

Scenario
XPO includes the XPQuery<T>  class tailored for constructing LINQ expressions against persistent objects. XPO to LINQ expressions are turned into pure database queries. That is, an expression is processed on the database server side, and only the requested objects or a scalar value are loaded onto the client

This example illustrates several sample queries such as:
- Group Join
- Select with Where and OrderBy clauses
- Select Top 5 objects 
- Aggregated Functions




For implementation details, see the Form1.xx file.

Important notes:

1. To evaluate expression on the server, use Expression<Func<T>> instead of Func<T> . 

2. The maximum allowed number of total or group summaries is 14.

3. The FirstOrDefault method does not support the property initialization in the Select statement.

4. Cross Join queries are not supported.

See Also:
.NET Language-Integrated Query 
eXpress Persistent Objects > Feature Center > Querying a Data Store > LINQ to XPO
How to: Implement Custom Functions and Criteria in LINQ to XPO  
XPQueryExtensions.Query<T>  
XPQueryExtensions.QueryInTransaction<T> 
How to populate a List View with data from a LINQ query

How to load unique (distinct) data via XPO

$
0
0

Scenario

This example illustrates how to load unique data via XPO. It is useful when your database contains a great amount of duplicated data and you need to find only unique values.
There are three approaches for this task:

XPView 
Use the XPView component, add the required properties to it, and set the properties' Group attribute to True.

LINQ
Use the XPQuery<T> class to construct LINQ expressions with the Distinct method.

PersistentAlias
Use Free Joins to build criteria based on persistent objects that are not directly related.




For implementation details, see the Form1.xx and NorthwindObjects.xx files.

See also:
Querying a Data Store

ASPxGridView - Batch Edit - How to validate the entered cell value on the server side

$
0
0

This example illustrates how to check a value entered in the cell on the server side. Checking is performed immediately after changing a value of a cell's editor. Set the "AAA" value to the C3 column or "BBB" to the C5 column for testing.

How to merge pages in PDF

$
0
0

This example illustrates how to use PDF Document Processor  for merging pages of two separate PDF files into a single PDF file.

Question Comments

Added By: Adriana Monterrubio at: 11/6/2014 11:52:24 AM    

Is there a way to merge two pages in only one page?

Added By: Elliot (DevExpress Support) at: 11/7/2014 1:28:01 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T170308: Is there a way to merge two pages in only one page?. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

How to retrieve data from Client Dashboard Item and display it using different ASP.NET controls

$
0
0

To request data displayed in the specific Dashboard Item, you should call GetItemData methods of the ASPxClientDashboardViewer object. 
Then, you need to iterate through the item's elements (rows, cells, points, etc ), collect information about corresponding dimensions and measures and store it as JSON collection. You can send this collection to the server in a string format using the JSON.stringify Function. To parse the string on the server, you can use the Json.Decode Method

Note that if you wish to display an underlying data source data, you can use the RequestUnderlyingData method instead of the GetItemData one.

Viewing all 7205 articles
Browse latest View live


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