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

How to view persistent objects in the XtraGrid and edit them in a separate window

$
0
0

Scenario
This example demonstrates how to view persistent objects in the XtraGrid and edit them in a separate window in the scope of UnitOfWork , so that changes made to the object's properties can be saved or canceled. This approach helps implement a comfortable UI for data input. 

Steps to implement:
1. 
Add GridControl to a Form and use XPCollection as a DataSource as described in the Tutorial 4 - A Windows Forms Application for Data Editing article.
2. Add BarManager with 3 BarButtonItems and handle the Click event as shown in the FormViewOrders.xx file. These buttons will be responsible for creation, modification and removing persistent objects. 
3. Add a second Form that will be used for persistent object modifications. This form will use the UnitOfWork class to work with the passed persistent object. Unit of Work keeps tracking every change to every persistent object during transaction that can affect a data store. With a single call of the UnitOfWork.CommitChanges method, all the changes made to the persistent objects are automatically saved to a data store.  For implementation details, see FormEditOrder.

 

See Also:
Unit of Work 
XPO Best Practices
Connecting to a Data Store
%Public%\Documents\DevExpress Demos 14.1\Components\WinForms\CS\ContactManagement\


OBSOLETE - How to edit a persistent object on a Web page

$
0
0

==================================================
This article is now obsolete.
Use the approach from Tutorial 5 - An ASP .NET Application for Data Editing to edit persistent objects by using the ASPxGridView control.
================================================== 

This example uses the FormView component, which is bound to XpoDataSource with a single object in it. The XpoDataSource is filtered by the Oid key. A QueryString field supplies a value for the criteria parameter.

A local SQL Server is required to launch the example. You should run the DatabaseUpdater project first to create a database and fill it with data. Then set XpoWebApplication as a startup project and launch it. Data is displayed in the ASPxGridView. When the Edit link is clicked, a new page with the FormView is open for object editing.

See Also:
How to use XPO in an ASP.NET (Web) application

How to use the XPPageSelector with the GridControl

$
0
0

Scenario
This article illustrates how to use the XPPageSelector component to provide Pager functionally to the XtraGrid control. This functionality is useful when you need to show data in small portions.

Steps
1. 
Create a new Windows Forms Application.
2. Add DXperience ORM Data Model Wizard to the application and use the Generating Persistent Objects for Existing Data Tables  approach to generate persistent objects from an existing database.
3. Add the XPCollection component to a Form and set the ObjectClassInfo property to the generated persistent object type to populate this collection with required objects.
4. Add the XPPageSelector component to the Form and set the Collection property to XPCollection.
5. Add GridControl  to the Form and use the XPPageSelector as a data source.
6. Add two Buttons and a Label. These controls will be responsible for page navigation.
7. Handle Button.Click events and create a method, which will update Label text as shown in the Form1.xx file.

Important notes:
Please note that paging is not applicable to the XtraGrid, as the grid requires the entire collection to correctly apply any sorting, grouping or filtering. Therefore, grouping, sorting and filtering will only be applied to the current page when the grid is bound to the XPPageSelector component. We suggest that you use the Server Mode  feature instead.

See also:
Tutorial 1 - Your First Data-Aware Application with XPO
How to: Bind an XPCollection to the Grid  

Question Comments

Added By: Vikas Gupta 7 at: 11/28/2012 3:24:44 PM    

Thanks for the code - but it's not working for me - I have tables with Schema for ex: Business.Files
In the class I am using
namespace ForeSight.Business
{
    public class Files : XPLiteObject
    {
         int fFileID;
        [Key(true)]
        public int FileID
        {
            get { return FileID; }
            set { SetPropertyValue<int>("FileID", ref fFileID, value); }
        }
        ... and more fields
     }
        public Files(Session session) : base(session) { }
        public Files() : base(Session.DefaultSession) { }
        public override void AfterConstruction() { base.AfterConstruction(); }
}

I am setting up the xpoDefault connectionstring by
XpoDefault.ConnectionString = MSSqlConnectionProvider.GetConnectionString(@"localhost\sqlexpress", "DatabaseName");
The application runs but
The problem is each time it runs it creates a new table name in the database named dbo.Files (which obviously is empty) thus shows nothing....

I got your example application and created a similar application and verified the code - but found nothing abnormalities...

What am i doing wrong?
let me know if can get you more information thanks

LINQ to XPO

How to use XPO with a Web Service

PageControl - How to load content when an active tab is changed using different action methods

$
0
0

Sometimes it's required to load different models and action method on a tab click. There are two ways to accomplish this task: 
1)  Use the $.ajax function in the ActiveTabChanging  event handler to accomplish this task;
2)  Use our built-in mechanisms for this task. The reloadContentOnCallback property allows you to send a callback to the server to reload the content of the page being activated. However in this case, the PageControl instance will be reloaded as well. 

How to: Use MessageBoxService in View Models derived from the ViewModelBase class

$
0
0
This example demonstrates how to use the MessageBoxService in View Models derived from the ViewModelBase class

How to generate items in TileNavPane from a collection

$
0
0

This example demonstrates how TileNavPane can be used with the MVVM pattern. TileNavPane has three levels: categories, items and subitems. To generate categories, bind a collection to the TileNavCategory.CategoriesSource property. To generate items, use TileNavCategory.ItemsSource. If it's necessary to generate subitems, use the TileNavItem.ItemsSource property. 


How to implement custom dropdown row editor for DXGrid

$
0
0

This example demonstrates how to edit grid row using the dropdown panel with editors generated automatically based on the underlying row data object. To see this approach in action, click the "Edit" hyperlink in the "#" grid column. To close dropdown panel click "Edit" again.
This functionality is achieved by creating the attached behavior which generates the necessary DataRowTemplate for the grid row. The custom template can also be defined and assigned to the GridHelper.CustomTemplate property, so the custom template will be used instead the autogenerated template.

Question Comments

Added By: Fakhru Izuh at: 8/27/2014 1:08:02 AM    

Hi,

Following example works fine for single select. However, when user selects all rows using Ctrl + A and then try to click 'Edit' link of any row, it doesn't show editing control.

How to: Pass data between View Models through the ISupportParameter interface

$
0
0
This example demonstrates how you can pass data between View Models through the ISupportParameter interface.

How to use the Service mechanism in a custom View Model

$
0
0
This example demonstrates how you can implement the support of the Service mechanism in a custom View Model (not derived from the ViewModelBase class and not a POCO View Model)

How to configure dxDataGrid with Angular Approach

$
0
0

This example demonstrates how to display data from a data source in dxDataGrid created using the AngularJS approach.

See also:
Configure Widget - Angular Approach

Question Comments

Added By: Marion (DevExpress Support) at: 8/12/2014 6:21:57 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T139489: How to configure dxDataGrid with Angular approach and handle the optionChanged event. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Scott Wood at: 8/27/2014 6:12:41 AM    

The demo code is incomplete.  dataSource:employees...   Where does employees come from?  I assume it's just a plain old javascript array????

How to create a 2D Overlapped Range Bar chart

$
0
0

The following example demonstrates how to create a 2D Overlapped Range Bar chart.


Question Comments

Added By: Gary Gaughan-Smith at: 8/27/2014 4:56:47 AM    

HOW to do this by Binding to Data? Now that would be very useful. I cannot find any examples

Added By: Constant (DevExpress Support) at: 8/27/2014 7:04:45 AM    Please refer to the Lesson 2 - Bind Chart Series to Data to see how to accomplish this task. It is only necessary to create the RangeBarOverlappedSeries2D series and customize their BarWidth Property.

How to сreate a сustom Edit Appointment form using the MVVM pattern

$
0
0
This example demonstrates how to substitute the standard Edit Appointment form with the custom one using the MVVM approach. The new technique is based on a service provided by a data template. This service allows displaying a form in a separate window. 

See also: 
How to: Create a Custom Edit Appointment Form Using the MVVM Pattern (step-by-step guide)

Question Comments

Added By: Cliff Knasinski at: 8/27/2014 9:05:27 AM    

I have an issue with using this example to commit the changes to my custom field back to the MS SQL Server database.  I am utilizing a design structure that is not represented in the examples from DevExpress.  I am using a LINQ to SQL class as my data model, and View Models to bind to those models.

Since I am unable to use the LINQ .CommitChanges method from the custom appointment form since I cannot send it as a parameter to the constructor using this example.  My View Model reflects the changes made by the form since it is bound two ways, but I have no way to fire off the .CommitChanges method.  

I noticed there is a ..

<Button x:Name="btnOk"
               Content="OK"
               Command="{Binding SaveAppointmentCommand}" MinWidth="75" Margin="6,0,0,0"/>

But this command is not used in the example.  I have not delved into commands yet, is there an example I can use that would allow me to fire off a method in the View Model this is bound too in order to commit changes to the database?

How to add the DocumentPanel at runtime

$
0
0

Find the necessary group by its name and use the DockManager.GetItem method. Add a new DocumentPanel to this group using the
AddDocumentGroup method. To activate this panel, call the DockController.Activate method.

Question Comments

Added By: Todd Stewart at: 8/27/2014 8:45:44 AM    

I tried this sample today and found an error.  Initially there are two tabs loaded in the Document Group.  If you close these two tabs and then hit the Add New Tab button the new tab is not shown in the Document Group.

Added By: Alexander Rus (DevExpress Support) at: 8/27/2014 11:12:34 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T144748: DocumentPanel is destroyed when it becomes empty. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.


How to implement the master detail GridView with editing capabilities

$
0
0

This example illustrates how to implement the master detail GridView with editing capabilities.
Perform the following steps to define the master-detail layout:
1) Define both master and detail GridView settings within separate PartialView files (see the Using Callbacks);
2) Set the master grid's SettingsDetail.ShowDetailRow property to "True";
3) Define the master grid's DetailRow content via the SetDetailRowTemplateContent method and render the detail grid's PartialView inside.

Note:
Values passed in a detail grid's CallbackRoute must have a unique name and must not replicate any other names on a page: Q577974: GridView - "The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32'" error occurs when canceling editing in the detail GridView

Question Comments

Added By: Wilson Vargas at: 10/20/2012 12:08:04 PM    

This sample not compile!

 settings.DataBinding = (sender, e) => {
            ((MVCxGridView)sender).ForceDataRowType(typeof(DevExpress.Razor.Models.Person));

Added By: WillAutio at: 3/24/2014 1:37:52 PM    

Excellent - just what I needed!

Added By: Paul.Astramowicz@thyssenkrupp.com Paul.Astramowicz@thyssenkrupp.com at: 8/27/2014 12:21:12 PM    

Hello Support,

Is there a ASP.NET version for this exact same example?  Please supply URL link......  thanks.

How to set up binding for a web report using a collection of custom objects as a data source at design time

$
0
0

This example illustrates how to bind a report to lists for web projects at design time. To do this you need to extract your reports together with the corresponding classes representing your business objects into a separate assembly. Then, you can easily perform all necessary design-time binding using the BindingSource component (by specifying the required object type as its DataSource).

This approach differs from how this is done under the Windows Forms platforms in that you cannot assign your object to the BindingSource.DataSource property at design time. Instead, you should perform the binding right within the InitializeComponent method.

Question Comments

Added By: CodeGal at: 1/21/2014 7:21:17 PM    

So what are the design time bindings for controls set to in the report?

Added By: Olena at: 3/5/2014 5:03:22 PM    

Hi Support Team,
I've just downloaded Example and I see error in the XtraReport1.cs tab saying

"Could not find type 'Reports.Data'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU. "

Unfortunately there is no ability to attach print screen.
What can I do to fix it?

Thanks!

Added By: ghsPt at: 4/7/2014 10:21:33 AM    

Hello!

I have a dataset with several objects.
If I want a list of several different objects with only one datasource, how can I do that?

Added By: Matt_Olson at: 7/20/2014 3:57:26 PM    

Missing design time objects in xtrareport1.cs

Added By: Andrew L (DevExpress Support) at: 7/21/2014 7:21:26 AM    Hello Matt,

To process your recent post more efficiently, I created a separate ticket on your behalf: T131788: E1936 - Missing design time objects . This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Matt_Olson at: 7/21/2014 8:03:37 AM    

Sorry, I see that the missing source code is in the Example Runner download.  It is only missing from the web viewable portion (such as definition for InitializeComponent()) which is in XtraReport1.designer.cs I'm guessing which isn't in the web viewable version.

Added By: Andrew L (DevExpress Support) at: 7/21/2014 10:02:49 PM    Hi Matt,

I am happy to hear that the problem has been resolved. Thank you for letting us know of your progress. Please feel free to contact us if you have any further difficulties. We will be happy to assist youAdded By: Lisa Bencic at: 8/27/2014 1:52:19 PM    

I run this example in my 14.1 environment and it works fine.  If I swap out the Report Viewer for the ASPxDocumentViewer, I get the old "Object reference not set...."
Is there an example that uses ASPxDocumentViewer?  
I saw in this link: http://www.devexpress.com/Support/Center/Question/Details/T119505
That it's 'NOT' good to store the Xtrareport in a session variable, that it is too complex.  Is it more complex with the Doc Viewer instead of Report Viewer?

How to reference an external workbook

How to display a route line with multiple pushpins on a map using a KML file

$
0
0

This example demonstrates how to load a shape from a KML file and display it on a map control.

To do this, create a KMLFileLoader object and assign it to the VectorLayer.ShapeLoader property. Then, specify the path to a KML file using the KmlFileLoader.FileUri property.

Note that if you run this sample as is, you will get a warning message saying that the specified Bing Maps key is invalid. To learn more about Bing Map keys, please refer to the How to: Get a Bing Maps Key tutorial.


How to implement ASPxGridView Multi-Row editing using ASPxHiddenField in the Master-Detail scenario

$
0
0

This example demonstrates how you can implement the Multi-Row editing for ASPxGridViews in the Master-Detail scenario. The ASPxHiddenField control is used to store edited values and to send data to the server.

The advantages of this approach:

- the edited values will not be missing after the grid's callbacks (sorting, filtering, paging).

- in the datasource, only changed rows will be updated


The main idea of this approach is to put the ASPxHiddenField in the Title template, so it will be updated on all grid's callbacks, and its data will be accessible on GridView's events. Each DataItem editor has its own client-side ASPxClientEdit.ValueChanged event handler to save its data to the hidden field with a corresponding key based on the column's field name and row key value. When the "Apply Changes" button is pressed, a callback is sent to the server by calling the client-side ASPxClientGridView.PerformCallback method. In the server-side ASPxGridView.CustomCallback event handler, data is loaded from the hidden field and saved to the datasource.

See also:
The general technique of using the Init/Load event handler
How to create a DataItem template for a grid column at runtime
A simple example of master-detail grids with editing capabilities

How to implement the multi-row editing feature in the ASPxGridView
How to perform ASPxGridView instant updating using different editors in the DataItem template

Question Comments

Added By: Angela Pearman at: 1/17/2013 10:41:13 AM    

I copied the code exactly from this sample. I imported the Nwind Db. But when I run it, edit a field, then hit 'apply changes' I get error 'Invalid key '1_productname'. Then when I click OK (only option), I get 'first character '1' in the property name "1_ProductName" is invalid. Property name can contain letters, digits, underline characters, and dollar signs. It can't begin with a digit character."

Added By: Angela Pearman at: 1/17/2013 11:02:35 AM    

ok, I figured out the problem. In the class EditableDataItem I changed the fieldkey to string.Format("{1}_{0}". This puts the number at the end of the field name. It worked that way.

Added By: Paul.Astramowicz@thyssenkrupp.com Paul.Astramowicz@thyssenkrupp.com at: 8/28/2014 7:27:45 AM    

Hello Support,

Is there any way you can try running this example using the latest version of DEvExpress in ASP.net?  Just wondering if it will work.   Version=14.1.5.0

Viewing all 7205 articles
Browse latest View live


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