How to: Use DXBinding, DXCommand, DXEvent
ASPxGridView - How to implement showing/hiding columns in the manner similar to ASPxPivotGrid
The example demonstrates how to implement showing/hiding ASPxGridView columns in the manner similar to ASPxPivotGrid. To accomplish this, perform the following steps:
1. Place the ASPxPopupMenu control on a page. Add two items with such names as "HideColumn" and "ShowHideList".
2. Handle the client-side ASPxClientGridView.ContextMenu event. Show a popup menu if a user clicks on the grid's header.
3. Handle the client-side ASPxClientPopupMenu.ItemClick event. Check on which item the user has clicked and perform proper manipulations. If an item's name is "HideColumn", perform a grid's callback via the ASPxClientGridView.PerformCallback method and pass the required column name. In the ASPxGridView.CustomCallback event handler hide a column whose name we can get using e.Parameters. If an item's name is "ShowHideList", show or hide the grid's CustomizationWindow.
See also:
How to show/hide grid columns via ASPxPopupMenu (client-side version)
How to show/hide grid columns via ASPxPopupMenu
Question Comments
Added By: Kam Loong Ting at: 12/9/2016 1:27:59 AM Hi, can you show this in MVC?
How to exclude holidays from the DateTime scale
This example illustrates how to configure the DateTimeScaleOptions.WorkdaysOptions Property to exclude holidays from the DateTime scale. The Workdays property is used to specify which days of the week are workdays, and the Holidays property contains information about holidays.
ASPxGridView - How to expand all group levels containing a data row with a certain key value
This solution involves expanding all rows in ASPxGridView and then successively collapsing rows, which do not contain required records.
Since this approach requires iterating through all rows, it can take time in the case of a large amount of rows in a grid. Also, this approach cannot be applied if a grid is utilized in server mode.
How to bind ASPxTokenBox to a large data source
This example demonstrates how to bind ASPxTokenBox to a large data source using WebMethods on the client side.
Create the GetFilteredData method that should return a list of items based on a string filter parameter. Then, handle the client-side ASPxClientTokentBox KeyUp event and execute the GetFilteredData method.
Create the setData method on the client side. After that, remove items that were added earlier and add new items to the TokenBox item collection in the setData method. Note that for certain purposes, it is possible to disable adding custom tokens using the AllowCustomTokens property.
To reduce the server overload by avoiding unnecessary requests, it is recommended to add the ASPxClientComboBox.BeginUpdate and ASPxClientComboBox.EndUpdate methods. Then, set them at the beginning and end of the keyUp event handler.
Finally, add a condition to check if the input value length is more than the minFilterLength variable and add timeout to allow a user to input the entire text and then show obtained items. Handle the client-side ASPxClientTokenBox.TokensChanged event and remove all items from the drop-down window.
Note: item highlighting will not work.
How to dynamically add a WebChartControl to a web page
This example demonstrates how a chart can be generated and shown in a web page with an ASPxButton click.
Note that prior to accessing elements and properties of a dynamically created WebChartControl, it should be added to the Page.Form.Controls collection.
See also: How to add a WebChartControl to the ASPxCallbackPanel on its callback.
Question Comments
Added By: Ricidleiv Tondatto at: 7/1/2014 11:59:45 AM
I'm not able to do that using version 11.1. The chart is a crashed image. What's wrong?
Added By: John (DevExpress Support) at: 7/2/2014 2:34:31 AM Hi Ricidleiv,I have created a separate ticket for your question: How to dynamically add a WebChartControl to a web page in version 11.1 Let's continue the conversation there.
Getting started lesson 3 - create a chart using series template
How to bind drop-down widgets to a remote ASP.NET Web API service and implement server-side filtering and paging
This example illustrates how to implement remote operations for the dxSelectBox, dxLookup, and dxTagBox widgets if data is obtained from a remote ASP.NET Web API service.
To do this, it is not necessary to implement a custom store manually and you can to create it using the DevExpress.data.AspNet.createStore method implemented in the dx.aspnet.data.js library. This library is a part of the DevExtreme.AspNet.Data data layer extension for ASP.NET MVC. The attached example illustrates how to integrate this library to an MVC 5 application and create a DataSource for the mentioned widgets.
If you need to implement more custom logic, follow the instructions from the dxLookup - Why the "Lookup/byKey callback was not defined" error is thrown when clicking an item if data is loaded from a web service help topic to create a CustomStore instance manually.
How to add a brick with vertical text to the margin of each report page
This example illustrates how to draw a custom vertical text into the left page margin. To accomplish this task, the LabelBrick element is added to the page's inner bricks collection in the XtraReport.AfterPrint event handler.
How to: Declare a context menu for DXTabControl tabs
How to export GridView data to different text formats
This example is standalone implementation of the online Grid View - Exporting Data demo.
It illustrates how to export the GridView 's content to several rich text formats via the ExportTo*** methods.
This example is an illustration of the KA18639: How to export GridView rows and keep end-user modifications (such as sorting, grouping, filtering, selection) KB Article. Refer to the Article for an explanation.
Please note the following key moments:
- The GridView Extension should be defined via a separate PartialView without any additional tags (see the Using Callbacks help topic for more information);
- The GridView's PartialView should be wrapped within a form in order to apply the client layout state (sorting, filtering, etc.);
- An export trigger should submit this form to the corresponding Controller Action (i.e., make a POST request);
- The GridViewSettings (especially the Name property) should be the same in PartialView and Controller;
- The datasouce/Model should be the same in PartialView and Controller.
Question Comments
Added By: Nurhak Kaya at: 9/4/2012 7:58:55 AM
Really good! Thanks a lot!
Added By: Steven Jansick at: 7/11/2014 11:44:57 AMDoes this work when binding with BindToCustomData?
I have verified that all of the Conditions have been met but when I export, it is not maintaining the Grouping Order. Do you have any recommendations?
Added By: Mike (DevExpress Support) at: 7/14/2014 12:05:58 AMHello,
To process your recent post more efficiently, we copied it to a separate ticket created on your behalf: T128968: GridView - Export Data when using BindToCustomData method.
This ticket is currently in our processing queue. We will post to it as soon as we have any updates.
How I can send filter parameter to excel export function.
Here is my Button Code .cshtml view
@using (Html.BeginForm("ExportExcel", "Dataset", new { datasetID = Convert.ToInt64(ViewContext.RouteData.Values["datasetID"]) }))
{
Html.DevExpress().Button(settings =>
{
settings.Name = "btnExportDatasetData";
settings.Width = 100;
settings.Text = "Export to XLS";
settings.UseSubmitBehavior = true;
settings.Images.Image.IconID = IconID.ExportExporttoxls16x16office2013;
}).GetHtml();
}
Here is my Grid Code cshtml, what I want is to take parameters from grid Filter and pass it to my Controller
@Html.DevExpress().GridView(settings =>
{
settings.Name = "DatasetDataGrid";
settings.CallbackRouteValues = new { Controller = "Dataset", Action = "DatasetDataBindingPartial", datasetID = Convert.ToInt64(ViewContext.RouteData.Values["datasetID"]) };
settings.CustomBindingRouteValuesCollection.Add(GridViewOperationType.Paging, new { Controller = "Dataset", Action = "DatasetDataBindingPaging" });
settings.CustomBindingRouteValuesCollection.Add(GridViewOperationType.Sorting, new { Controller = "Dataset", Action = "DatasetDataBindingSorting" });
settings.CustomBindingRouteValuesCollection.Add(GridViewOperationType.Filtering, new { Controller = "Dataset", Action = "DatasetDataBindingFiltering" });
i want to put here Condition if user click on button then it take filter parameter, otherwise won't.
//if (settings.AfterPerformCallback != null)
{
settings.CustomBindingRouteValuesCollection.Add(GridViewOperationType.Filtering, new { Controller = "Dataset", Action = "ExportExcel" });
}
//settings.ClientSideEvents.EndCallback = "";
settings.Width = Unit.Percentage(100);
settings.Styles.Cell.CssClass = "CellsEllipsis";
settings.Settings.HorizontalScrollBarMode = ScrollBarMode.Visible;
settings.SettingsPager.PageSize = 50;
settings.SettingsPager.PageSizeItemSettings.Visible = true;
settings.SettingsPager.PageSizeItemSettings.Items = new string[] { "10", "20", "50", "100" };
settings.Settings.ShowFilterRow = true;
//settings.Settings.ShowFilterBar = GridViewStatusBarMode.Visible;
settings.Columns.Add(col =>
{
col.FieldName = "FactID";
col.Caption = "Fact ID";
});
if (Model != null && Model.Columns != null)
{
foreach (GridViewColumnState column in Model.Columns)
{
if (column != null)
{
if (column.FieldName != "FactID")
{
settings.Columns.Add(column.FieldName);
}
}
settings.Columns[settings.Columns.Count - 1].HeaderStyle.Font.Bold = true;
settings.Columns[settings.Columns.Count - 1].Width = Unit.Pixel(150);
}
}
settings.HtmlDataCellPrepared = (sender, e) =>
{
if (e.CellValue != null)
{
e.Cell.ToolTip = e.CellValue.ToString();
}
};
settings.ClientSideEvents.Init = "function(s,e) { s.PerformCallback(); }";
}).BindToCustomData(Model).GetHtml()
here is my Controller Action Method,
public ActionResult ExportExcel(Int64 datasetID, GridViewFilteringState filteringState)
{
var viewModel = GridViewExtension.GetViewModel("DatasetDataGrid");
viewModel.ApplyFilteringState(filteringState);
var results = DatasetDataBindingCoreExcel(viewModel);
DevExpress.Web.Mvc.GridViewSettings settings = new DevExpress.Web.Mvc.GridViewSettings();
settings.Styles.Header.BackColor = System.Drawing.ColorTranslator.FromHtml("#1E76AE");
settings.Styles.Header.ForeColor = System.Drawing.ColorTranslator.FromHtml("#FFFFFF");
settings.Styles.AlternatingRow.Enabled = DevExpress.Utils.DefaultBoolean.True;
settings.Styles.AlternatingRow.BackColor = System.Drawing.ColorTranslator.FromHtml("#D9E7FA");
settings.SettingsExport.RenderBrick = (sender, e) =>
{
DevExpress.Web.GridViewDataColumn dataColumn = e.Column as DevExpress.Web.GridViewDataColumn;
if (e.RowType == DevExpress.Web.GridViewRowType.Data &&
dataColumn != null &&
(dataColumn.FieldName.ToLower() == "iscurrent" || dataColumn.FieldName.ToLower() == "ispublished"))
{
e.TextValue = e.Value == DBNull.Value ? "False" : (Convert.ToBoolean(e.Value) ? "True" : "False");
}
};
//settings.Columns.Add("ProgrammeID");
settings.Name = "datasetExport";
DatasetModel obj = dsrepo.GetDatasetInfo(datasetID);
settings.SettingsExport.FileName = String.Format("{0}_{1}_{2}", obj.Title, obj.Code, DateTime.UtcNow.ToShortDateString());
//settings.CallbackRouteValues = new { Controller = "Exporting", Action = "ExportPartial" };
//settings.Width = DevExpress.Web.Unit.Percentage(100);
return Who.Xmart.Helpers.GridViewExportHelper.GridViewExport.ExportFormatsInfo[Helpers.GridViewExportHelper.GridViewExportFormat.Xlsx](settings, results);
//return Who.Xmart.Helpers.GridViewExportHelper.GridViewExport.ExportFormatsInfo[Helpers.GridViewExportHelper.GridViewExportFormat.Xlsx](settings, dsrepo.GetDatasetData(datasetID));
}
Added By: Jenny (DevExpress Support) at: 11/28/2016 10:10:20 PM
Hello Qasim,
I've created a separate ticket on your behalf (T456166: GridView - How to export the filtered grid to excel). It has been placed in our processing queue and will be answered shortly.
How to bind a grid control to the worksheet data
This example demonstrates how to bind the Grid Control to the Spreadsheet data. To do this, use the Range.GetDataSource method to create a data source object from a specific cell range in a worksheet, and then assign it to the GridControl.DataSource property. The two-way binding is supported: any changes to worksheet (such as editing values, inserting and deleting rows, sorting and filtering) are immediately propagated to the Data Grid, and editing data in the grid is reflected in the spreadsheet.
How to bind a grid control to the worksheet data (WPF Spreadsheet)
This example demonstrates how to bind the Grid Control to the Spreadsheet data. To do this, use the Range.GetDataSource method to create a data source object from a specific cell range in a worksheet, and then assign it to the GridControl.ItemsSource property. The two-way binding is supported: any changes to worksheet (such as editing values, inserting and deleting rows, sorting and filtering) are immediately propagated to the Data Grid, and editing data in the grid is reflected in the spreadsheet.
WinForms SpreadsheetControl API - Part 3
This example is the third part of the SpreadsheetControl API set of examples that demonstrates how to use the SpreadsheetControl API to programmatically manage spreadsheet documents, without the need for Microsoft Excel to be installed.
This sample introduces API properties and methods used to perform the following operations:
- Apply data validation to control the type of data or the values that users enter into a cell
Starting from v2016 vol.2:
- Remove rows and columns that meet the specified condition
How to override the Report Designer command handlers using a custom ReportDesignerCommands class descendant
This example illustrates how to create a custom command provider inherited from the ReportDesignerCommands class and override some of its methods.
TreeList - How to reorder sibling nodes
This example demonstrates how to move TreeList sibling nodes using Drag&Drop.
To preserve the node order, it is necessary to set up an extra column to store node order indexes. Then, sort TreeList nodes by this column and deny sorting by other columns. This example stores this information in a dynamically created column and the logic of swap nodes is implemented in the action method from TreeList.SettingsEditing.NodeDragDropRouteValues. We have implemented this approach only for demo purposes. You can store this information in your DataSource.
See also: E3850: How to reorder ASPxTreeList sibling nodes, using buttons or drag-and-drop
How to: Implement a Custom Geocode Provider
How to enable editing in a group row so it is possible to change child cell values
This example illustrates how to show an editor in a group row under a corresponding column. The editor corresponds to an in-place editor used in the column.
To invoke the group editor click the group row once or twice based upon the GroupEditProvider.SingleClick property. Then, you can enter any value in this editor. To apply this value to child cells and close the editor you should either press the Enter key or force the editor to lose focus. To discard changes press the Esc key when the group editor is active.
Also, you can provide end-users with a visual effect pointing that he/she can invoke the group editor for a group row located under the mouse pointer. For this, enable the GroupEditProvider.ShowGroupEditorOnMouseHover property.
Question Comments
Added By: Andrew Xi at: 7/4/2014 5:48:33 AM
It is super! I am using DevExpress WPF and looking for this feature in WPF. How could I have this feature in WPF with DevExpress?
Added By: Andrew Ser (DevExpress Support) at: 7/4/2014 6:28:47 AMHello,
I've extracted your inquiry into a separate ticket - How to enable editing in a group row so it is possible to change child cell values. We will answer you there.
Thanks in million, that is really help the World --- given the group fiunctionality allowing sigle typing to update all the childen, and that could enghiten the users everywhere
Added By: Thibaut Fourment at: 12/14/2016 7:58:27 AM Hi ! Same question here. I'd really like to use this feature in WPF. But I don't have access to the private link you sent.Any idea how to have this feautures in WPF with DevExpress ?
Many thanks,
Thibaut Added By: Svetlana (DevExpress Support) at: 12/14/2016 10:40:11 AM
Hello,
I've created a separate ticket on your behalf (T462696: How to enable editing in a group row so it is possible to change child cell values). It has been placed in our processing queue and will be answered shortly.
How to display a custom text within the ProgressBar, working in in-place mode
This sample shows how to force the progress bar to show both the progress and custom text within a ProgressBar cell
Question Comments
Added By: heriberto lugo at: 12/14/2016 9:08:37 AM why so complicated? so much work for something trivial?
wouldnt it be much more logical to be able to set the text when increment is called? without having to additionally handle an event?
im very confident chances are very high that the data associated with the custom text is decided in the same scope of code in which the dev calls increment. why force the dev to pass the data for custom text elsewhere?
sigh..... Added By: Svetlana (DevExpress Support) at: 12/14/2016 12:27:07 PM
Hello,
I've created a separate ticket on your behalf (T462731: ProgressBarControl - How to set a custom display text). It has been placed in our processing queue and will be answered shortly.
How to reorder ASPxTreeList sibling nodes, using buttons or drag-and-drop
This example demonstrates how to move TreeList nodes using buttons or Drag&Drop.
To persist the node order, it is necessary to set up an extra column to store node order indexes. Then, sort TreeList nodes by this column and deny sorting by other columns. This example stores this information in a dynamically created column and additionally, puts a dictionary "node key = node index" in the session. We have implemented this approach only for demo purposes. You can store this information in your DataSource.
See also:
T462559: TreeList - How to reorder sibling nodes
TreeList - How to implement node reordering
Question Comments
Added By: darryl deen at: 12/12/2012 9:07:52 AM
Any example of this using your ASP.NET MVC extensions?
Also, is there an example where you can move all the nodes anywhere. i.e. move a child node to another parent in a specific spot/order?