This example demonstrates how to enlarge dates in the DateEdit's calendars when hovering the mouse.
How to extend the editor without inheriting it, so dates are enlarged in the DateEdit's calendar when you are hovering over them with the mouse
How to filter data on the server side with XtraReports Parameters
The criteria you specify in the XtraReport.FilterString property is applied to data source rows by the report control on the client side by default. When working with large data sets, it makes sense to apply this filter directly to the data source to avoid excessive data transfer. This task can be accomplished by creating the following scripts in the report:
[C#]privatevoidxafReport1_BeforePrint(objectsender,System.Drawing.Printing.PrintEventArgse){DevExpress.Data.Filtering.OperandValue[]prameterOperands;DevExpress.Data.Filtering.CriteriaOperatorcriteria=DevExpress.Data.Filtering.CriteriaOperator.Parse(xafReport1.FilterString,outprameterOperands);foreach(DevExpress.Data.Filtering.OperandValuetheOperandinprameterOperands){DevExpress.Data.Filtering.OperandParameteroperandParameter=theOperandasDevExpress.Data.Filtering.OperandParameter;if(!object.ReferenceEquals(operandParameter,null)){DevExpress.XtraReports.Parameters.Parameterparam=xafReport1.Parameters[operandParameter.ParameterName];if(param!=null)operandParameter.Value=param.Value;}}DevExpress.ExpressApp.Reports.XafReportxafReport=(DevExpress.ExpressApp.Reports.XafReport)xafReport1;IListoriginalDataSource=xafReport.ObjectSpace.GetObjects(xafReport.DataType,criteria);xafReport1.DataSource=newDevExpress.ExpressApp.ProxyCollection(xafReport.ObjectSpace,DevExpress.ExpressApp.XafTypesInfo.Instance.FindTypeInfo(xafReport.DataType),originalDataSource);}privatevoidxafReport1_DataSourceDemanded(objectsender,System.EventArgse){xafReport1.DataSource=null;}
Question Comments
Added By: Gustavo Marzioni at: 4/2/2013 12:10:16 PM
Why this funcionality, that is very important is not included in XafReport??
Added By: Ken Gliddon at: 2/10/2014 10:39:38 PMPlease help with this report parameters. If I add it to the script the parameters panel on the report shows yet when select a parameter it generates the SQL query which fails saying Conversion failed when converting from character string to uniqueidentifier, the parameter sample seems to fail when using the Oid from the selected paramters
Added By: Adrian D Ilie at: 2/16/2014 12:04:24 AMWhat happens if a parameter is a non-persistent property, which cannot be automatically translated into a SQL query for server filtering? A simple example: a non-persistent IsActive property that looks at two persistent properties, StartDate and EndDate, and returns true if today's date falls between them, or EndDate is null. Filtering by IsActive is performed on the client, correct? Is filtering by other criteria, which do not rely on non-persistent properties, performed automatically on the server? I ask because I can, with some effort, translate the algorithm that computes the non-persistent property into a script that creates the same condition but relies exclusively on persistent properties, which can be filtered on the server. This effort would be worth my time if having a single non-persistent property causes filtering to be performed on the client, without taking advantage of the other persistent properties which can be filtered on the server.
Added By: Gustavo Marzioni at: 11/24/2015 6:48:51 AMI have to use it in DataSourceDemanded not in BeforePrint, because it don't work for child collections
ASPxGridView – How to filter by null and empty cell values using Filter Bar when FilterMode is DisplayText
When a header filter is used for a column and its FilterMode is set to “DisplayText”, the predefined “(Blanks)” criterion returns rows with values equal to null or empty, whereas in a grid’s Filter Bar the “Is blank” condition will not return anything.
This can be described by the fact that in the former case, the resultant CriteriaOperator will be built as “IsNullOrEmpty”, while in the latter case it will be “IsNull”. In order to make Filter Bar work in the same way, it’s possible to parse its filter expression and replace IsNull operator with the required IsNullOrEmpty.
This example uses a parsing technique demonstrated in E3396: How to delete all criteria corresponding to a particular field from CriteriaOperator. In this case, the CriteriaHelper class was slightly modified so that the UnaryOperator of type IsNull is replaced by the FunctionOperator of type IsNullOrEmpty.
The modified filter expression is applied on a grid’s callback.
(Obsolete) How to implement CRUD operations with RestStore
This example is obsolete. Please refer to the How to implement CRUD operations with a DataSource example.
This example demonstrates how to implement CRUD operations with RestStore.
See also:
How to implement the Rest service based on an ASP.NET WebAPI application
Question Comments
Added By: Randy Desormeaux at: 1/23/2013 8:32:53 AM
Great, example!
I would like to see more done with the DevExpress.data.RestStore.
btw the "Example" link does not work.
Added By: Gary Zambrano Andrade at: 3/25/2013 7:23:55 AMHello, good example and the function is correctly, congratulations.
I have a question:
How to insert the foreign key (CategoryId) in product table?
Hi,
This example is not working with V15.1.7. Could you please update it
Added By: Nikolai (DevExpress Support) at: 11/25/2015 11:43:07 PM Hi Mohammed,This example is obsolete. Please refer to the How to implement CRUD operations with a DataSource example.
ASPxGridView - Using GridViewDataComboBoxColumn as a lookup control
This demo implements lookup functionality using the following two techniques:
- "Category LookUp" column editor populates its drop-down list from the bound CategoriesDS data source.
- "RunTime LookUp" column editor is populated via code in the PageLoad event.
Question Comments
Added By: tien dat at: 11/8/2012 7:06:08 PM
I'm using ver 12.1 demo.I did it like that but it can't be look up.I still use button Edit to select value in combo box.
i wandering what element make it to be lookup.Thanks a lot
After much searching...this is my solution, great example! Thanks
Added By: Frost at: 11/25/2015 1:49:30 PMThe RunTime data set repeats in your demo and doubles the list size due to the page_load postback.
Added By: Nataly (DevExpress Support) at: 11/26/2015 1:33:58 AMHello,
To process your recent post more efficiently, I created a separate ticket on your behalf: T317103: ASPxComboBox bound at runtime has duplicated items in the "Using GridViewDataComboBoxColumn as a lookup control" code example. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.
How to display a custom work week and holidays
Problem:
In Kuwait weekly holidays are Friday and Saturday. Sunday to Thursday are working days. How can I implement this in the XtraScheduler? Also I'd like to show official holidays in the Scheduler and in the DateNavigator and highlight them.
Solution:
You should use the SchedulerControl.WorkDays collection to accomplish this task. Add the required weekdays and holidays to the collection.
To change the highlight color of the date in the DateNavigator control, handle its CustomDrawDayNumberCell event or specify a custom painter with the DateNavigator.CellStyleProvider property for version 15.2 and higher.
To change the header captions for holidays handle the SchedulerControl.CustomDrawDayHeader event. Consider also using Formatting Services as an alternative technique.
OBSOLETE - ASPxHtmlEditor – How to insert a link with an image
OBSOLETE:
Starting with version 15.1 custom dialog froms are not supported.
ASPxHtmlEditor provides a rich API to edit Html content including the capability to operate built-in toolbars. However, sometimes the embedded functionality is not enough, and you may wish to add a custom feature to the default functionality. For instance, ASPxHtmlEditor does not allow end-users to choose an image when inserting a link. Such tasks can be easily implemented by extending built-in dialog forms.
This example illustrates how to enlarge a built-in dialog form, in particular add an image chooser to the InsertLinkForm dialog. To utilize this scenario, perform the following steps:
1. Extract built-in ASPxHtmlEditor dialog forms to your application folder:
Design Time -> ASPxHtmlEditor's Smart Tag - > “Copy Default Dialog Forms to the Project" command;
2. Add ASPxUploadControl to the InsertLinkForm.ascx page to allow end-users to choose a desired image;
3. Modify the OnOkButtonClick_InsertLinkForm function as follows:
a) If ASPxUploadControl does not contain any file, call the aspxDialogComplete method to insert a link without an image;
b) If ASPxUploadControl contains a file (an upload editor has text), first upload the file and save it to a psychical folder. After completing this operation, call the aspxDialogComplete method to insert a link with an image:
[JScript]function OnOkButtonClick_InsertLinkForm(){if(IsValidFields_InsertLinkForm()){if(_dxeUplImage.GetText() != ""){ _dxeUplImage.Upload();}else{ aspxDialogComplete(1, GetDialogData_InsertLinkForm(""));}}}//ASPxClientUploadControl.FilesUploadComplete Event function aspxImageLinkUploadComplete(e){ aspxDialogComplete(1, GetDialogData_InsertLinkForm(e.callbackData));}
4. Handle the ASPxUploadControl.FileUploadComplete event to save the uploaded file to the application directory;
5. Send a path of the just saved file to the client side as the CallbackData parameter:
[C#]protectedvoiduplImage_FileUploadComplete(objectsender,DevExpress.Web.ASPxUploadControl.FileUploadCompleteEventArgsargs){try{args.CallbackData=SaveUploadFile();}catch(Exceptione){args.IsValid=false;args.ErrorText=e.Message;}}
6. To insert a link with an image, modify the GetDialogData_InsertLinkForm code as follows:
[JScript]if(image == ""){ res.text = _dxeTxbText.GetText();}else{ res.text = _dxeTxbText.GetText() + '<img alt="" src="' + image + '" />';}
The «res» contains text that will be inserted into ASPxHtmlEditor.
By design, ASPxHtmlEditor converts tags (e.g. <img>) to special symbols when inserting text. To prevent this, add the following non-public function to a JavaScript block:
How to load an excel file to the server using ASPxUploadControl and display its data in ASPxGridView
This example shows how to load an excel file from your computer to the server using ASPxUploadControl and then display its data in ASPxGridView.
To do this, you first need to place the ASPxGridView and ASPxUploadControl controls on a page and, secondly, handle the ASPxGridView.Init event and both the server-side and the client-side ASPxUploadControl.FileUploadControl events.
After uploading the excel file from your computer, save it in the "~/XlsTables/" directory using the ASPxUploadControl.FileUploadControl event handler on the server-side. You may choose any filename and then save it in the Session["FileName"] object to use later.
In the ASPxGridView.Init event handler you need to check the value of the Session["FileName"]object. If it's null, do nothing. Otherwise create a new DataTable and DataTableExporter objects.
Question Comments
Added By: John Daren Dizon 1 at: 5/11/2015 8:43:46 PM
So how can I save the data uploaded in the grid into a database?
Added By: Sergi (DevExpress Support) at: 5/12/2015 12:25:35 AMHello,
To process your recent post more efficiently, I created a separate ticket on your behalf: T240435: ASPxGridView How to save data from Excel to a database. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.
I used this code. Version=14.1.6.0 visual studio 2012 version., But it shows a red line under(workbook) Workbook book = new Workbook();
How to send authenticated requests to the OData service
This example demonstrates how to send authenticated requests to the OData service. The main idea is to handle the ODataContext.beforeSend event and add login information to the header of your request.
See also:
How to process authenticated requests on the OData service
Question Comments
Added By: Phil Jenson at: 1/28/2013 3:12:21 AM
I believe 'beforeSend' function should be a member of the ODataContext and not a member of the CategoryList object.
Added By: Hasan Baidoon at: 7/9/2013 10:33:08 PMHi,
I want to know if this method for Basic Authorization works when JSONP is enabled.
Thanks.
Added By: Onkelinx Ghislain at: 2/13/2014 2:06:23 PMWhich version of visual studio works this example?
Added By: surekha at: 11/3/2015 2:26:49 AMTHis code is not worrking. error comes app not defined. how i can resolve this error.
Added By: Mark Hartmann at: 11/3/2015 2:34:36 AMChange line "app.navigate('Login');" to navigate to your login page according to your other code.
Added By: Nikolai (DevExpress Support) at: 11/3/2015 7:32:12 AM Hi Guys,Surekha, please follow the recommendations from the Mark's comment. If this does not help, describe how we can reproduce the issue with this example. We will do our best to assist you.Added By: Luong Tu at: 11/29/2015 6:16:39 PM
this example isn't working for me
How to process authenticated requests on the OData service
This example demonstrates how to process authenticated requests on the OData service. The main idea is to override the DataService.OnStartProcessingRequest method and implement authenticated logic in it.
To access this service, use the following credentials:
UserName: John
Password: qwerty
See also:
OData and Authentication – Part 6 – Custom Basic Authentication
Salt (cryptography)
How to send authenticated requests to the OData service
How to: Use the XPO OData V3 Service
Question Comments
Added By: Jay Patel 15 at: 9/24/2013 11:33:27 AM
I was wondering why this project is not compatible with Visual Studios Ultimate 2010? Thanks
Added By: Joseph Tang 3 at: 10/10/2013 7:57:30 AMI used your code with the modification that it would check the AD for authentication. It works. However, it always popup the login window for entering the username and password.
Added By: Pedro Coutinho 1 at: 11/28/2013 3:22:33 AMHow can i get the userinfo from the database?
Added By: Pedro Coutinho 1 at: 11/29/2013 7:09:31 AMHow can i retrieve this users from a database?
Added By: George Yoder at: 1/25/2014 1:19:44 PMHow would you do authentication with sql membership provider????
Added By: Enderson Salas at: 7/29/2014 4:26:35 PMThis example no compile in Visual Studio 2013 because some assembly references are missing.
Added By: Nikolai (DevExpress Support) at: 7/30/2014 4:23:50 AMHello,
To process your recent post more efficiently, I created a separate ticket on your behalf: T135174: E4403 is not compiled in Visual Studio 2013. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.
Hello Dev express team,
Can you please explain me how to get my the user information from our DB, we use The Profile provider in ASP.NET Membership & Users, and how to integrated to this Authentication process?
************************* YOUR SAMPLE CODE************************
namespace MyDataService {
public class CustomBasicAuth {
class UserInfo {
public string Name { get; set; }
public string PasswordHash { get; set; }
public string[] Roles { get; set; } }
static UserInfo[]
Users = new[] { new UserInfo {
Name = "John",
PasswordHash = "F3U89ry4+MMXyqbbT90tcs18J5Y=",
Roles = new[] { "User", "Admin" } } };
************************************************************************
My Tables:
aspnet_Users:
UserID
UserName
aspnet_Membership:
UserID
Password (encripted)
aspnet_Roles:
RoleID
RoleDescripcion
aspnet_UsersInRoles:
UserID
RoleID
Regards
Pedro Perez
Hello Pedro,
To process your recent post more efficiently, I created a separate ticket on your behalf: T262586: How to select users from DB in authenticated data service. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.
When I debug this webservice and go to this link http://localhost:65443/MyDataService.svc. It throw an error 'Invalid login or password'. How can I access this service? I don't know how to use UserName: John, Password: qwerty you gave me.
How to create a custom GridView, which will take into account custom drawing of a group row when exporting and printing data
WPF Rich Editor Layout API - Simple Example
How to open documents using ASPxFileManager
This example demonstrates how to open a file which is selected in ASPxFileManager. The ASPxClientFileManager.SelectedFileChanged event is handled to send a callback to the server, and open the file using ASPxSpreadsheet or ASPxRichEdit inside a popup.
Page Builder - MultiColumn - How to start a new column
Use the Band.PageBreak property or the XRPageBreak control. To 'activate' a page break at certain positions only, apply a formatting rule (Visible = true) with the following condition to XRPageBreak:
([DataSource.CurrentRowIndex] + 1) % [Parameters.paramRecCount] == 0 And [DataSource.CurrentRowIndex] < [DataSource.RowCount] - 1
End-User Designer - How to customize the control's Smart Tag menu
This example demonstrates how to customize the XRLabel's Smart Tag menu to make the following properties available: Text, Data Binding (the Text property), WidthF, HeightF, LocationF.X, LocationF.Y.
To achieve this, we do the following:
1. Implement a DevExpress.XtraReports.Design.XRControlDesigner descendant and override XRControlDesigner.RegisterActionLists to provide a custom action list.
2. Create a custom report control by subclassing a required control (Creating Custom Controls) and register the custom control on the toolbox by using the design-time IToolboxService service.
For more information on adding custom controls to the Toolbox and removing standard ones from it, check the following articles:
How to: Register a Custom Control in the End-User Designer's Toolbox.
How to: Make a Custom Control be Available Only for a Specific Report Instance
3. Link this designer to the custom XRControl by using the XRDesigner attribute.
See also:
How to create custom report controls
How to programatically invoke the smart tag once an XRControl is added to report in the WinForms End-User Designer
How to programatically invoke the smart tag once an XRControl is added to report in the WinForms End-User Designer
See also:
End-User Designer - How to customize the control's Smart Tag menu
How to use aggregate functions in Calculated Field expressions
To calculate a group sum (for example), use the approach from the How to conditionally suppress summary footer cell painting by using formatting rules code example. Please note that you can use the '^' symbol in expressions to refer to a currently processed data record.
How to customize a Subreport once it has been created by double-clicking the XRSubreport control in the End-User Designer
Override the OpenSubreport designer command to accomplish this task. Use the following approach: How to: Override Commands in the End-User Designer.
How to dynamically group a report based on a parameter value
The main idea is to handle the XtraReport.BeforePrint event, clear the GroupHeader.GroupFields collection, and then add a new GroupField item based on a parameter value.
How to list all groups and their summaries at the end of the report
Place two separate DetailReportBands to your report and bind them to the same data source. The main report's data source shouldn't be set. The first DetailReportBand will display plain data without any grouping. In the second DetailReportBand, group data by any field and place required summary fields there.