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

How to show the Sort Dialog in a grid in a similar manner as in Excel

$
0
0

This example illustrates how to provide an end-user with the Sort Dialog allowing him/her to customize sorted columns. Also, it is possible to show sort indexes of the sorted columns in their column headers by setting the SortDialogProvider.ShowSortIndexInColumnHeader property to true.

NOTE: If you are using version earlier than 10.2 handle the GridView.ShowGridMenu event rather than the GridView.PopupMenuShowing event in the SortDialogProvider class.


How to allow an end-user to rename TreeListColumn at runtime

$
0
0

This example illustrates how to add a new item to the TreeListColumn context menu to show TextEdit within a column header area and implement renaming a column as follows.

How to display EF objects in a grid within master-detail mode when entities have many-to-many relationship

$
0
0

This example illustrates how to show entities related with many-to-many relation in a grid within master-detail mode when an entity model contains a linked table.



See also:
A master-detail grid with Entity Framework objects

Question Comments

Added By: karl balinggao at: 3/10/2013 2:12:43 PM    

HI sir,
thank you very much for providing such helpful example. It really made my day. Also just want to ask what if I want to load another level inside the detail? IS that possible?

How to change colors of a highlighted text corresponding to a search string of Find Panel

$
0
0

This example illustrates how to customize foreground and background colors of a search string highlighted within located records in a grid.


Question Comments

Added By: anonimo at: 12/11/2013 2:17:30 PM    

I need some similar but using memoEdit, how can I do It?

DropDownBox - How to filter data of a nested widget when a user types text into the editor

How to use SearchControl for TileControl

ASPxGridView - How to utilize CRUD operations with LinqDataSource and Anonymous Types

$
0
0

With the LinqDataSource you can create Web pages that enable users to update, insert, and delete data. When you bind the LinqDataSource control with the LINQ to SQL Classes, it performs editing operations via a generated DataContext. You do not need to specify SQL commands, because the LinqDataSource uses dynamically created commands for those operations. To let users modify data, you can enable update, insert, or delete operations on the LinqDataSource control.


Often, ASPxGridView editors are rendered as read-only. This happens because Anonymous Types are generated, but LINQ does not allow editing anonymous types. You can read more about this in the Anonymous Types (C# Programming Guide) MSDN article. A possible solution is to handle the ASPxGridView.CellEditorInitialize event and set the e.Editor.ReadOnly property to false for those columns which appear as readonly.

Another solution is to populate the grid with a strong type collection. For example:

[C#]
protectedvoidLinqDataSource2_Selecting(objectsender,LinqDataSourceSelectEventArgse){DataClassesDataContextcontext=newDataClassesDataContext();varobj=fromiincontext.ProductsselectnewMyProduct(){ProductID=i.ProductID,ProductName=i.ProductName,SupplierID=i.SupplierID,CategoryID=i.CategoryID,QuantityPerUnit=i.QuantityPerUnit};e.Result=obj;}}publicclassMyProduct{publicintProductID{get;set;}...}

LinqDataSource uses a ViewState to store previous values in it. As ASPxGridView works in callback mode, it is necessary to disable the ViewState or set the LinqDataSource.StoreOriginalValuesInViewState property to false.

How to convert the CriteriaOperator to a lambda expression to use it for IQueryable

$
0
0

Imagine, that an end-user can build a filter criteria, e.g. by using the FilterControl, and you wish to apply this filter criteria to your IQueryable source.

The static DevExpress.Data.Linq.Helpers.CriteriaToQueryableExtender class allows you to add extended methods for the IQueryable source, such as AppendWhere method, for example. This method provides a capability to create a new IQueryable source, based upon the existing one, and add an additional Where condition to it. So, you can convert the CriteriaOperator to the corresponding lambda expression without any problem.

To extend the IQueryable source, it is sufficient to add the DevExpress.Data.Linq.Helpers namespace.

Please note that the DevExpress.Data.Linq.Helpers.CriteriaToQueryableExtender is an inner class, and we cannot guarantee that it will not be changed in the future.


How to create a custom editor allowing you to display a readonly HTML formatted text

$
0
0

This example illustrates how to create a custom editor to display a readonly HTML formatted text. In standalone mode you can use the LabelControl instead.

To show the HTML formatted text in a grid you can assign the RepositoryItemRichTextEdit to an appropriate column. However, the RichEditControl is quite a complex and "heavy" control. So, if you only need to show the HTML formatted text in the grid without editing it the best way to get it done is to assign a custom RepositoryItemHtmlLabel to a column. Note that the HtmlLabelViewInfo implements the IHeightAdaptable interface. So, this custom control supports the word wrapping feature and grid's row auto height feature will work properly.

Question Comments

Added By: Anders Wang at: 9/26/2015 1:06:06 AM    

Hi
How to make the text in the cell can be selected? Thanks.

Added By: Andrew Ser (DevExpress Support) at: 9/28/2015 12:39:31 AM    Hello Anders,
I've extracted your inquiry into a separate thread - How to display selectable HTML text in grid cells. Let's discuss this question there.

How to use the vertical grid for in-place editing and in view mode

How to set custom names for grid filters and save/restore these names with a grid layout

$
0
0

When an end-users applies any filter to a grid, this filter is shown in the Filter Panel. When the AllowMRUFilterList property is set to true, recently used filters can be accessed via the View's MRU Filter List. It is a convenient way to access previous filters. Since filters can contain multiple filter conditions, it is not always comfortable to search for a necessary filter in the MRU Filter List. This example illustrates how to provide an end-user with the capability to set custom short names for filters. This way, a custom filter name will be shown in the Filter Panel as well as in the MRU Filter List.

To implement this feature, we have created a custom FilterNameProvider class. Create this class object and pass your GridView to its constructor. Once it is done, set the FilterNameProvider.AllowSettingFilterNames property to true to enable this functionality.

Now, when you right-click a filter text in the Filter Panel, a context menu will be shown. Click the Save Filter As item to invoke FlyoutDialog. In this FlyoutDialog, you can enter a custom filter name for the current filter shown in the Filter Panel.

So, your end-user can now assign custom short names for filters. However, this information will be lost once you save and restore a grid layout. To save custom filter names with the grid layout, we use the XmlXtraSerializer.SerializeObjects method. We pass the current GridView together with a FilterNameProvider object to this method. FilterNameProvider has the GridFilters property of the List<GridFitlerItem> type, which is intended to be serialized. That is why this property is marked with the XtraSerializableProperty attribute. Note that properties of the GridFitlerItem class are also marked with this attribute.

To restore these filters, we use the XmlXtraSerializer.DeserializeObjects method. Since new GridFitlerItem objects will not be created automatically when this method is called, it is necessary to declare a special method at the FilterNameProvider class to allow you to create such objects manually. This method should have a name according to this pattern: “XtraCreate<PropertyName>Item”. That is why we call this method as XtraCreateGridFiltersItem

ASPxGridView - How to indicate that a column belongs to a particular Band column

$
0
0

This example demonstrates how to indicate that a column belongs to a particular Band column in a Customization Window of ASPxGridView. To achieve this, handle the ASPxGridView.Init event and assign different colors and tooltips to columns headers, which belong to a particular band column.

[C#]
protectedvoidASPxGridView1_Init(objectsender,EventArgse){foreach(varcolumninASPxGridView1.Columns){if(columnisGridViewBandColumn){GridViewBandColumnfirstLevelColumn=(GridViewBandColumn)column;intindex=firstLevelColumn.Index;if(index> 9)index%= 10;firstLevelColumn.HeaderStyle.BackColor=suitableColors[index];foreach(varsubcolumninfirstLevelColumn.Columns){GridViewDataColumnsecondLevelColumn=(GridViewDataColumn)subcolumn;secondLevelColumn.HeaderStyle.BackColor=suitableColors[index];secondLevelColumn.ToolTip=string.Format("This column belongs to {0} column",firstLevelColumn.Caption.ToString());}}}}

How to extend the LayoutControl's context menu to set an image for a layout item?

$
0
0

This example demonstrates how to add the custom DXMenuItem items to the LayoutControl's context menu to provide the capability to show/hide a picture in an item's label.

How to add a new row to a grid by typing in a New Item Row as in DataGridView

$
0
0

If you want to exactly emulate the standard DataGridView behavior, i.e. the new item row should appear immediately after typing in a column's cell, you need to introduce this functionality manually.

For this, set the GridView.OptionsView.NewItemRowPosition property to Bottom.
Then, handle the RepositoryItem.EditValueChanged event:
      close the active editor and post changes by calling the GridView.CloseEditor method,
      then call the GridView.UpdateCurrentRow method to save a new row to the underlying data source.
To show the cell's in-place editor again, call the GridView.ShowEditor method.

This example illustrates how to accomplish this task.

Question Comments

Added By: Dave Conrad at: 9/4/2015 11:16:53 AM    

Attempted to use this code...

Testing the code, i enter a value into one of the cells, as I press my first key, at the following line... (I'm using the vb version)

GridView.UpdateCurrentRow

I get a popup error...

The column 'pkid' does not allow nulls.  Do you want to correct the value (Yes or no) - if I click yes, it just keeps popping up the message infinitely.

I have tried setting the pkid value before UpdateCurrentRow method, with a line of code as such...

ApTxDistAdvBandedGridView.SetRowCellValue(ApTxDistAdvBandedGridView.FocusedRowHandle, "Pkid",fnMyPkidGenerator)

This however does not help, the error still occurs.  Pkid is a SQL Key from Microsoft SQL Server and does not allow nulls.  I am assinging keys programatically in code.

Also, the error popup does not seem to be trappable.  Maybe a function of the control itself ?

Hope you can help!

Screen capture here --> http://screencast.com/t/rk5qqAImJWY

Added By: Olga (DevExpress Support) at: 9/7/2015 8:02:35 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T286673: E2891 code example - An exception is thrown on entering a new value. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

How to highlight dates existing in a data source in the grid's calendar filter drop-down

$
0
0

This example demonstrates how to highlight dates existing in a data source in the grid's calendar filter drop-down.


How to show a full text in tabs when panels are within an auto-hidden tabbed container

$
0
0

This feature is implemented natively starting from version 11.2.

In earlier versions, this example illustrates how to display a full text in tabs' captions when a tabbed panel is auto-hidden. This functionality is implemented by creating a custom SkinBarManagerPaintStyle.

How to create the LabelControl's descendant to support selecting and copying its text

$
0
0

There are circumstances when it's necessary to display any static information in the application. In these cases, the LabelControl or the TextEdit is used. The LabelControl has an important advantage - transparency, but it doesn't support selecting and copying its text. In turn, the TextEdit doesn't support transparency, but at the same time this editor allows an end-user to select & copy an arbitrary part of its content.

To obtain a control that will be own advantages of the TextEdit (selecting and copying of the text) and LabelControl (transparency), it's possible to inherit the LabelControl and implement the required functionality manually. This example demonstrates how this task can be accomplished.

Question Comments

Added By: Emanuel De Sousa at: 8/12/2014 11:35:13 PM    

Does not support HTML Text in the label.

Added By: Alexey Z (DevExpress Support) at: 8/13/2014 1:32:23 AM    Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T139757: Does not support HTML Text in the label. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

LookUpEdit.HeaderClickMode - How to work like both modes are enabled: Sorting, AutoSearch

How to implement an event to customize a filter string produced by the SearchLookUpEdit

$
0
0

Sometimes it is useful to adjust a string entered in the Find Panel based upon any rules and filter data correspondingly. For instance, if an end-user enters one two in the Find Panel data search will be performed according to whether or not either one or two string is contained in any search column. To search data against whole "one two"string it is necessary to enclose the filter string in quotes (please review the Find Panel help article to learn all capabilities of the Find Panel). To make this behavior default you can add the quotes to the filter string manually by handling the SearchLookUpEdit.UpdateDisplayFilter event.

This examples illustrates how to implement the SearchLookUpEdit.UpdateDisplayFilter event.

Question Comments

Added By: Carlos90210 at: 6/5/2013 11:17:30 AM    

Excellent solution, especially when running in server mode. Why this event is not included as default? it is almost impossible to catch events with linq in server mode.

Added By: Keith Palihakkara at: 7/10/2013 1:00:41 AM    

I can't seem to find this event on the SearchLookUpEdit in 13.1.5, has it been replaced?

How to show check boxes in RibbonControl as in Microsoft Office Word

$
0
0

This example illustrates how to create a custom RibbonControl that allows you to emulate check box behavior in the Ribbon of MS Word.

Viewing all 7205 articles
Browse latest View live


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