Grid for Xamarin - Feature Demos
How to drop an appointment from an external control onto an ASPxScheduler
This example illustrates how to drag and drop an item from an external control (ASPxGridView in this example) to the ASPxScheduler area in order to create an appointment. Note that this example is an extended version of the ASPxScheduler - How to drag a row from ASPxGridView and create an appointment based on its values code example. The advantage of this project is that an appointment is created in a time cell to which a corresponding grid item is dropped, whereas in the previous example, the appointment time is taken from a grid row.
Here is a screenshot that illustrates a sample application in action during the custom drag-and-drop operation:
See Also:
How to drop an appointment from ASPxScheduler to an external control
How to: Prevent Individual Cells From Being Edited
How to use a Background Geolocation in XAF Mobile
Scenario:
You want to automatically track movements of an XAF mobile application user and display the user's route on the map, e.g., in a separate administrative XAF Web application:
Your feedback is needed!
This is not an official feature of our Mobile UI (CTP) and our API may change in future release cycles. We are publishing this article prior to the 17.2 release to collect early user feedback and improve overall functionality. We would appreciate your thoughts on this feature once you've had the opportunity to review it. Please report any issues, missing capabilities or suggestions in separate tickets in our Support Center. Thanks for your help in advance!
Prerequisites
Install any v17.1.5+ version.
The implementation steps below are given for a new application, though they can be applied to any other XAF mobile app.
Steps to implement
1. Create a new XAF solution with Web and Mobile platforms and enable the Maps Module in it. Do not forget to specify the MapsAspNetModule > GoogleApiKey property in the Application Designer invoked for the YourSolutionName.Web/WebApplication.xx file.
2. In the YourSoltutionName.Mobile/MobileApplication.xx file, register the Cordova Background Geolocation plugin by adding required tags to the MobileApplication.AdditionalPhoneGapPlugins collection.
[C#]usingDevExpress.ExpressApp.MobilepublicpartialclassBackgroundGeolocationMobileApplication:MobileApplication{publicBackgroundGeolocationMobileApplication(){AdditionalPhoneGapPlugins.Add(@"<plugin name=""cordova-background-geolocation-lt"" source=""npm"" spec=""2.7.3""><variable name=""LOCATION_ALWAYS_USAGE_DESCRIPTION"" value=""Background location-tracking is required"" /><variable name=""LOCATION_WHEN_IN_USE_USAGE_DESCRIPTION"" value=""Background location-tracking is required"" /><variable name=""MOTION_USAGE_DESCRIPTION"" value=""Using the accelerometer increases battery-efficiency by intelligently toggling location-tracking only when the device is detected to be moving"" /><variable name=""LICENSE"" value=""YOUR_LICENSE_KEY"" /></plugin>");AdditionalPhoneGapPlugins.Add(@"<plugin name=""cordova-plugin-device"" source=""npm"" spec=""1.1.6""></plugin>");// ...
Take note of the line which adds the "LICENSE" tag. If you have a license key (refer to the corresponding remark in the README file), uncomment this code and replace the YOUR_LICENSE_KEY placeholder with your own key .[VB.NET]Imports Microsoft.VisualBasicImports DevExpress.ExpressApp.MobilePartialPublicClass BackgroundGeolocationMobileApplicationInherits MobileApplicationPublicSubNew() AdditionalPhoneGapPlugins.Add("<plugin name=""cordova-background-geolocation-lt"" source=""npm"" spec=""2.7.3"">"& ControlChars.CrLf &" <variable name=""LOCATION_ALWAYS_USAGE_DESCRIPTION"" value=""Background location-tracking is required"" />"& ControlChars.CrLf &" <variable name=""LOCATION_WHEN_IN_USE_USAGE_DESCRIPTION"" value=""Background location-tracking is required"" />"& ControlChars.CrLf &" <variable name=""MOTION_USAGE_DESCRIPTION"" value=""Using the accelerometer increases battery-efficiency by intelligently toggling location-tracking only when the device is detected to be moving"" />"& ControlChars.CrLf &" <variable name=""LICENSE"" value=""YOUR_LICENSE_KEY"" />"& ControlChars.CrLf &" </plugin>") AdditionalPhoneGapPlugins.Add("<plugin name=""cordova-plugin-device"" source=""npm"" spec=""1.1.6""></plugin>")' ...
3. In the YourSolutionName.Module project, copy the BackgroundGeolocation.Module\BusinessObjects\DeviceInfo.xx file to the BusinessObjects folder.
This file contains business classes used to store background geolocation data received from mobile clients. You may want to put these classes into separate files according to your code rules.
4. In the YourSolutionName.Mobile project, create a new Geolocation folder and copy the several code files below into it as per the instructions below.
4.1. Copy the BackgroundGeolocation.Mobile\Geolocation\GeolocationScript.js file and include it in the project. Change the Build Action property for this file to Embedded Resource. This code initializes the Cordova Background Geolocation plugin with default settings. Feel free to modify it according to your needs. More information about configuring options can be found in the project's github repository.
4.2. Copy the BackgroundGeolocation.Mobile\Geolocation\GeolocationJsonObject.xx file and include it in the project.
These classes are used to deserialize JSON data set by mobile applications to the Geolocation Service.
4.3. Copy the BackgroundGeolocation.Mobile\Geolocation\GeolocationHttpHandler.xx file and include it in the project.
The Background Geolocation plugin will send data to this service. The service is intended to save the device information to the database. It uses the connection string from the application configuration file (Web.config).
To enable the HTTP handler added on the previous step, add the following line to the configuration/system.webServer/handlers section of the YourSolutionName.Mobile/Web.config file (you may need to change the type attribute value and specify the namespace qualified name of the GeolocationHttpHandler class declared in your project:
[XML]<addname="Geolocation"verb="GET,POST"path="GeolocationProcessingService.svc"type="YourSolutionName.Mobile.GeolocationHttpHandler"/>
5. In the YourSoltutionName.Mobile/MobileApplication.xx file, register the GeolocationScript.js code (copied on step #4.1) using the MobileApplication.RegisterClientScriptOnApplicationStart method so that this script executes when the mobile application starts up on the device. The code snippet below demonstrates how to implement the ReadResource and ReadResourceString methods required to load the code from the embedded resource into a String variable (you can find this code in the BackgroundGeolocation.Mobile/MobileApplication.xx file of the sample project):
[C#]publicBackgroundGeolocationMobileApplication(){// ...stringgeolocationScript=ReadResourceString("BackgroundGeolocation.Mobile.Geolocation.GeolocationScript.js");RegisterClientScriptOnApplicationStart("GeolocationScript",geolocationScript);}publicstaticbyte[]ReadResource(stringresourceName){byte[]buffer=null;using(Streamstream=Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)){if(stream!=null){buffer=newbyte[stream.Length];stream.Read(buffer, 0,(int)stream.Length);}}returnbuffer;}publicstaticstringReadResourceString(stringresourceName){byte[]resourceBytes=ReadResource(resourceName);returnEncoding.UTF8.GetString(resourceBytes).Replace("\r\n","\\r\\n");}
[VB.NET]PublicSubNew()' ...Dim geolocationScript AsString = ReadResourceString("GeolocationScript.js") RegisterClientScriptOnApplicationStart("GeolocationScript", geolocationScript)EndSubPublicSharedFunction ReadResource(ByVal resourceName AsString) AsByte()Dim buffer() AsByte = NothingUsing stream As Stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)If stream IsNot NothingThen buffer = NewByte(stream.Length - 1){} stream.Read(buffer, 0, CInt(stream.Length))EndIfEndUsingReturn bufferEndFunctionPublicSharedFunction ReadResourceString(ByVal resourceName AsString) AsStringDim resourceBytes() AsByte = ReadResource(resourceName)Return Encoding.UTF8.GetString(resourceBytes).Replace(ControlChars.CrLf, "\r\n")EndFunction
The value passed to the ReadResourceString method consists of two parts in C# projects: the default assembly namespace ("BackgroundGeolocation.Mobile") and the path to the resource file ("Geolocation.GeolocationScript.js"). The first part may be different in your project. In VB.NET projects, the resource name will be much simpler: "GeolocationScript.js".
6. In the YourSolutionName.Module.Web project, install the Newtonsoft.Json NuGet package and copy the BackgroundGeolocation.Module.Web\Controllers\DisplayGeolocationController.xx file to the Controllers folder.
This controller is intended to draw the client's route based on location points.
7. Build and deploy your mobile application following the steps described in the Install the Application to a Smartphone help article, and ensure that the Geolocation services are enabled in the mobile device settings.
Once you get your mobile app running on your actual device, wait a few minutes and then run the Web version of your XAF application. Open the DeviceInfo List View, and you will see a record containing your mobile device information. If you click the ListView record, you will be navigated to the DetailView that contains the Map demonstrating the route tracked by the Background Geolocation module.
See Also:
eXpressApp Framework > Getting Started > XAF Mobile (CTP) Tutorial
How to: Use a Custom Plugin in a Mobile Application
XAF Mobile - Overview Video
FAQ: New XAF HTML5/JavaScript mobile UI (CTP)
Using Maps in a Mobile Application
How to send push notifications to the XAF Mobile application using Azure Notifications Hub
How to use a Barcode Scanner in XAF Mobile
Question Comments
Added By: Roman Max at: 8/22/2017 2:27:38 PM Hi, do you mind posting Project ZIP file here? Somehow having difficulty running it.Added By: Uriah (DevExpress Support) at: 8/22/2017 11:11:51 PM Hi Roman,
I've created a separate ticket on your behalf (T548156: Provide project ZIP file for T540129 example). It has been placed in our processing queue and will be answered shortly.
How to export HtmlEditor content via built-in toolbar button and via custom action button
This example is standalone implementation of the online HTML Editor - Import/Export demo.
It illustrates how to export the HtmlEditor's content to several rich text formats via a built-in toolbar item and custom Controller Action.
How to customize a dashboard before displaying it in a browser
This example demonstrates how to define a custom Dashboard Storage and override the LoadDashboard method that is used to load dashboards. From this method, you can update the loaded dashboard and provide the updated version to the MVCxDashboard control. In this example, a custom descendant of the DashboardFileStorage class is created. It allows defining the default parameter value and customizing the data source query to filter displayed data.
Question Comments
Added By: Marcin Mroczek at: 2/21/2018 6:30:33 AM Hello
Will it work with OLAP data source?
ASPxGridView - How to create HyperLink сolumn whose URL depends on several column values
Create a column's URL using the GridViewDataColumn.UnboundExpression property:
or use the HyperLinkProperties.NavigateUrlFormatString property to add extra text to the complete URL:[ASPx]<dx:GridViewDataHyperLinkColumnFieldName="HyperLinkColumn"UnboundType="String"UnboundExpression="'Default2.aspx?id='+[CategoryID]+'&name='+[CategoryName]"VisibleIndex="4"><PropertiesHyperLinkEditTextField="CategoryName"DisplayFormatString="Open <b>{0}<b/>"></PropertiesHyperLinkEdit></dx:GridViewDataHyperLinkColumn>
[ASPx]<dx:GridViewDataHyperLinkColumnFieldName="HyperLinkColumn2"UnboundType="String"UnboundExpression="'?id='+[CategoryID]+'&name='+[CategoryName]"VisibleIndex="4"><PropertiesHyperLinkEditTextField="CategoryName"DisplayFormatString="Open <b>{0}<b/>"NavigateUrlFormatString="Default2.aspx{0}"></PropertiesHyperLinkEdit></dx:GridViewDataHyperLinkColumn>
Using this approach, you will be able to preserve the full GridViewDataHyperLinkColumn functionality.
(Obsolete) A numeric editor with the input validation
In a simple situation, this task can be accomplished by assigning the numeric mask to the TextEdit editor. However, when editor is bound to the data source that allows Null values, editor might have no initial value assigned. In this situation, the type of value can't be resolved before the editor is validated. To overcome this problem, it's necessary to assign the value of appropriate type to the editor's EditValue property, before it is bound to the data. This example demonstrates how to implement the editor that perform this automatically. It can be used both as the stand-alone or in-place editor.
(Obsolete) How to highlight a text fragment in an editor
This example demonstrates how to use the internal mechanism intended to support the Incremental Search functionality, to highlight a portion of text in the editor, when the TextEditStyle property is set to TextEditStyles.DisableTextEditor, and its MaskBox is unavailable. This approach will work properly with all ButtonEdit descendants, except for editors derived from the PopupBaseAutoSearchEdit.
T575086: How to use the ASPxSpreadsheet control in an XAF ASP.NET WebForms application
I want to display my business object that has a byte array property as an Excel document allowing users to modify the content and save it to the database. ASPxSpreadsheet is an appropriate component for this task, but how to implement a Web Property Editor based on it?
Backgrounds
Unlike regular ASP.NET editors and controls, ASPxSpreadsheet is a front-end to a document service similar to Google Docs that will be running on your web site if you add this component to your application. Because of this, a property editor based on the ASPxSpreadsheet component has some specific features.
1. If a user opens a document, the next user who opens the same document will see the actual document content even if the first user did not save it to the database.
2. The Refresh action does not discard changes made in the document. The actual document state is stored in the service, and the content stored in the database is used as backup.
3. The Save action updates the content stored in the database. If the user closed a document without clicking the Save action, changes made to the document will be stored on the service and another user can save them to the database.
The property editor demonstrated in this example works with properties of a specific type - SpreadsheetDocument, and does not write any changes to a property. Instead, it modifies referenced objects directly. The SpreadsheetExample.Module\BusinessObjects\Report.cs (SpreadsheetExample.Module\BusinessObjects\Report.vb) file contains a class that has a property of the SpreadsheetDocument type. Note that this property is considered a part of the persistent object (that is why it has the Aggregated attribute) and automatically initialized with the value within the AfterConstruction method.
The editor implementation is simple. Refer to the SpreadsheetExample\SpreadsheetExample.Module.Web\Editors\SpreadsheetEditor.cs (SpreadsheetExample\SpreadsheetExample.Module.Web\Editors\SpreadsheetEditor.vb) file for details. It uses the ASPxSpreadsheet.Open and ASPxSpreadsheet.SaveCopy methods to synchronize the opened document with the database. Documents are identified by the persistent object's key property. This allows opening a separate document for each record in the database.
How to create editor that updates its value on mouse move
This example demonstrates how to implement the feature, when the value of the SpinEdit is automatically decreased or increased based on the cursor position, when the user moves the mouse holding down the left mouse button.
Question Comments
Added By: Joe How Hu¡ at: 8/18/2014 3:02:27 AM
Dear support, could you update the example with a sample code?
Thank you.
Added By: Jannet (DevExpress Support) at: 8/18/2014 3:12:32 AM Hello Sharon,I've updated this example. Please check whether or not code is visible and let me know your results.
(Obsolete) How to implement a pop-up edit form for GridView
This example is obsolete. In latest versions, we suggest using built-in feature: Edit Form
This example demonstrates how to edit the row in the GridView using the pop-up form. The editors for this form are generated automatically, based on the columns' editors. Please note: this solution is intended for creating a simple layout. In more complex situations, the best approach is to create the Edit Form for each GridView in the designer, and manually place editors.
How to highlight rows or columns by clicking on the field value
This example demonstrates how to implement a feature similar to the one implemented in the PivotGridControl. When the user clicks within the field value, corresponding rows or columns are highlighted.
To implement this feature, the ASPxLabelControl is added to the Field Value Template. The ASPxLabelControl handles the client side Click event, and sends the callback to save the value and area of the Field Value that is being clicked. The value and area are used within the ASPxPivotGrid.CustomCellStyle event handler, to determine whether the current cell belongs to the selected row or column.
Question Comments
Added By: Ganesh Kumar 20 at: 4/4/2014 12:10:24 AM
The code breaks at
string val = PivotGridValueType.GrandTotal == c.ValueItem.ValueType ? "Grand Total" : c.Value.ToString();
Throws a nullreference object error.
I have a ASPXPivotGrid which has columns arranged in the following way:-
Year->Month->"a certain value". when I am iterating through the headers (year and months ) there is no error but when the Init event reaches the subcolumns i.e. "a certain value", I get this exception. If we change the value of null to empty string the code works but there is not visual change in pivotgrid.
Added By: Ganesh Kumar 20 at: 4/4/2014 12:10:34 AMThe code breaks at
string val = PivotGridValueType.GrandTotal == c.ValueItem.ValueType ? "Grand Total" : c.Value.ToString();
Throws a nullreference object error.
I have a ASPXPivotGrid which has columns arranged in the following way:-
Year->Month->"a certain value". when I am iterating through the headers (year and months ) there is no error but when the Init event reaches the subcolumns i.e. "a certain value", I get this exception. If we change the value of null to empty string the code works but there is not visual change in pivotgrid.
How to implement a calculated property aggregating collection items
This example demonstrates how to calculate a sum of associated objects and display it as a property of a parent object. In this example, the XtraGrid is used to display master-detail XPO objects. When the Amount property of a child object is changed, the parent object's Totals property is automatically updated.
See Also:
How to calculate a master property based on values from a details collection
How to copy items into the SchedulerStorage datasource via drag and drop
The SchedulerControl manually handles the drag and drop operation and inserts a new object into the collection in addition to the object that will be inserted later.
This example demonstrates how to create a custom SchedulerStorage component that can address this problem. This component allows you to specify which object to insert into the datasource when a new appointment is added. The new object can be specified via the ObjectForInsert property of a custom Appointment.
How to display the password characters instead of text within the PropertyGridControl
To accomplish this task, create a RepositoryItemTextEdit, and set its PasswordChar property to any value. Then, within the OnCustomRecordCellEdit event handler assign a created RepositoryItemTextEdit to this cell, if the current property of the selected object has a PasswordPropertyText attribute.
(Obsolete) How to update merged RibbonPageCategory, RibbonPage and RibbonPageGroup
When the RibbonControl is merged to another RibbonControl, the RibbonPages, the RibbonPageCategories and the RibbonPageGroups aren't added to this RibbonControl. This RibbonControl shows their copies instead. These copies are available via the RibbonControl.MergedPages and the RibbonControl.MergedCategories properties. This example demonstrates how to update these elements at runtime.
How to synchronize the selection in the GridControl and the PivotGridControl
This example demonstrates how to select data in the PivotGridCotnrol based on the selected cell in the GridControl.
How to get rid of the space reserved for an image in a TreeListNode
When the TreeList.SelectImageList or TreeList.StateImageList properties are assigned, each TreeListNode has an indent to draw these images, even if the TreeListNode.SelectImageIndex or TreeListNode.StateImageIndex properties are set to -1.
In a situation when this behavior is undesirable, it's possible to create a custom TreeList descendant, and change it by overriding the TreeListViewInfo.GetDataBoundsLocation method.
Question Comments
Added By: Daniel Parsons at: 7/7/2015 12:06:05 PM
Corrected code as follows:
protected override void CalcStateImage(RowInfo ri)
{
base.CalcStateImage(ri);
if (Size.Empty != RC.StateImageSize && -1 == ri.Node.StateImageIndex)
ri.StateImageLocation.X -= RC.StateImageSize.Width;
}
I missed Daniel's comment and spent a few hours before coming to the same conclusion... Added By: Nadezhda (DevExpress Support) at: 11/7/2017 6:45:17 AM
Hello Jacobo,
We will update this example as soon as possible. We appreciate your patience.
there has a bug, if override the CalcStateImageBounds function, the treelist's GetStateImage event will not be eraising!
Added By: waresofter at: 12/21/2017 3:06:03 AM
[C#]usingDevExpress.XtraEditors;usingDevExpress.XtraTreeList;usingDevExpress.XtraTreeList.Nodes;usingDevExpress.XtraTreeList.ViewInfo;usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;namespaceDevSample{publicpartialclassFrmTreeList:XtraForm{publicFrmTreeList(){InitializeComponent();this.treeList1.FocusedNodeChanged+=TreeList1_FocusedNodeChanged;List<Record>records=newList<Record>(newRecord[]{newRecord(1,"test1","i can raising focusNodeChanged event"),newRecord(2,"test2","i can raising focusNodeChanged event")});this.treeList1.DataSource=records;}privatevoidTreeList1_FocusedNodeChanged(objectsender,DevExpress.XtraTreeList.FocusedNodeChangedEventArgse){Recordrec=this.treeList1.GetDataRecordByNode(e.Node)asRecord;System.Diagnostics.Debug.WriteLine(rec.Name);}classRecord{publicintIndex{get;set;}publicstringName{get;set;}publicstringDescription{get;set;}publicRecord(){}publicRecord(intidx,stringname,stringdesc){this.Index=idx;this.Name=name;this.Description=desc;}}privatevoidbuttonEdit1_ButtonClick(objectsender,DevExpress.XtraEditors.Controls.ButtonPressedEventArgse){if(e.Button.Caption=="添加记录"){TreeListNodetln=this.treeList1.AppendNode(newobject[]{"a4","b4","c4"},-1);treeList1.FocusedNode=tln;treeList1.OptionsBehavior.Editable=true;treeList1.ShowEditor();}}privatevoidtreeList1_GetStateImage(objectsender,DevExpress.XtraTreeList.GetStateImageEventArgse){System.Diagnostics.Debug.WriteLine("treeList1_GetStateImage");Recordrec=this.treeList1.GetDataRecordByNode(e.Node)asRecord;e.NodeImageIndex=rec.Index% 2 == 0 ?-1 : 0;}}publicclassMyTreeList:TreeList{/******************************************************** * 当节点前没有图片时,去除图片占位符 * https://www.devexpress.com/Support/Center/Example/Details/E2153/how-to-get-rid-of-the-space-reserved-for-images-in-the-treelistnode-when-a-certain * * ******************************************************/publicMyTreeList():base(){}protectedoverrideTreeListViewInfoCreateViewInfo(){returnnewMyTreeListViewInfo(this);}// 当某个节点前没有图标时,不显示图标的占位空间publicclassMyTreeListViewInfo:TreeListViewInfo{publicMyTreeListViewInfo(TreeListtreeList):base(treeList){}protectedoverridevoidCalcSelectImageBounds(RowInforInfo,RectangleindentBounds){System.Diagnostics.Debug.WriteLine("CalcSelectImageBounds: "+rInfo.Node.SelectImageIndex);if(Size.Empty!=RC.SelectImageSize&&-1 ==rInfo.Node.SelectImageIndex)return;base.CalcSelectImageBounds(rInfo,indentBounds);}protectedoverridevoidCalcStateImageBounds(RowInforInfo,RectangleindentBounds){System.Diagnostics.Debug.WriteLine("CalcStateImageBounds: "+rInfo.Node.StateImageIndex);if(Size.Empty!=RC.StateImageSize&&-1 ==rInfo.Node.StateImageIndex)return;base.CalcStateImageBounds(rInfo,indentBounds);}}}}
Added By: Nadezhda (DevExpress Support) at: 12/21/2017 7:42:13 AM Hello,
I have created a separate ticket on your behalf: The GetStateImage event does not fire when the CalcStateImageBounds method is overrided. It has been placed in our processing queue and will be answered shortly.
How to change the data source of the DataLayoutControl at runtime
Usually, to display different data based on the user choice, the predefined UserControls are used to display data in the most convenient manner for the end user. This sample, demonstrates how a single DataLayoutControl can be used for this purpose.