If you’re using Infragistics WebHierarchicalDataGrid and getting “DataKeyField is invalid” error after assigning DataKeyFields property for the root level:
xMyGrid.DataKeyFields = "[Key 1],[Key 2],[Key 3]"
and trying some data manipulation (like deleting rows, binding data etc.), try using GridView property of the grid instead:
If you ever need to remove namespaces from an XPath string, regex is a way to go. [\w]+:(?!:) expression to be precise. So if, for example your xpath is
Dim sXpath as String = "/ns1:ElementOne/ElementTwo/ns2:ElementThree"
this code
Regex.Replace(sXpath, "[\w]+:(?!:)", "")
will convert it into
/ElementOne/ElementTwo/ElementThree
Thanks Bogdan Emil Mariesan @ Stack Overflow for the solution
By default if server-side filtering is enabled in UltraWebGrid controls, it displays a small “funnel” icon in the column header, if you click this icon – a list of unique values from this column is displayed and selecting a value filters the grid by displaying only rows that have this value.
This default behavior works, sort of – it has many issues. If your grid has paging enabled – only values from the current page will be displayed. If your columns or values has characters that grid doesn’t like (commas, square brackets etc.) an exception will be thrown (this happens because under the hood grid converts your filters into a string that is passed to DataTable’s RowFilter), there’re other issues as well.
ADO.NET DataTable offers handy RowFilter property (via its DefaultView object), for example to filter by some string value and display filtered data in a grid a code like this is used:
where odtMyData is a DataTable object and odgDataGrid is a Data Grid.
This works well, but what if you need preprocess data in the DataTable prior comparing it to the filter value – what if you need to apply a user-defined function to it? In my case I had a VB function called ProcessTags which stripped HTML tags from a string, so for example strings like this:
<a href="http://someurl">This is a sample text</a>
and this
<span style="color:red">This is a </span><label>sample text</label>
would be converted into the same text
This is a sample text
So I needed to create condition that would return DataTable rows with that have both HTML values by comparing to "This is a sample text".
How? RowFilter‘s syntax is pretty poor and external function cannot be used, so something like
odtMyData.DefaultView.RowFilter = "ProcessTags(Field) = 'This is a sample text'"
odgDataGrid.DataSource = odtMyData
odgDataGrid.DataBind()
Infragistics UltraWebGrid offers rich client-side programming model, but often it can be extremally slow. As an example consider a simple task: Given a particular Row ID hide the rest of the grid rows, keeping only this row visible.
Using UltraWebGrid’s CSOM (Client Side Object Model) JavaScript code looks like this:
var oGrid = igtbl_getGridById('xMyGrid'); // Get reference to grid object
for (var sRowID in oGrid.Rows) { // Looping thru all rows in grid's rows collection
if (sRowID != sSelectedRowID) { // If current row ID is not given ID
igtbl_getRowById(sRowID).setHidden(true) // Get reference to row and hide it
}
}
Infragistics UltraWebTab control offers multiple styling options, many of them can be set via external CSS classes. As a matter of fact about only element you cannot style via external stylesheet is rounded corner images. Or can you?
By default images used to give the tabs rounded-corner look are referenced directly in UltraWebTab ASPX markup:
Would set style of grid header and rows via external CSS class. You would expect that simple defining classes like this:
.HeaderStyle { /* style definition goes here */ }
.RowStyle { /* style definition goes here */ }
should do the trick, but you may experience some unwanted, erratic behavior: styles getting lost, styles getting mixed up (row would get a header style and vise versa).
To fix this we should let grid know that header style should apply only to header row (THEAD/TH HTML elements) and row style applies only to rows with data (TBODY/TD elements). This is done via slight adjustments of the above CSS to point it to specific elements:
This way there’s no confusion, styles apply exactly were they belong. Also you may need to set grids MergeStyles property to False and make each class fully define it’s element (including fonts, colors, backgrounds etc.)
If you’re still using classic Infragistics Controls and want to make them work in modern browsers, sometimes a little additional work is required. Hopefully this little trick will save you some time.
UltraWebGrid has a neat property TopItemSpacing, when set to Auto it automatically spreads top level menu items across the menu control, giving them nice spacing in between. Unfortunately this property seems to work in Internet Explorer only, in Firefox (and Chrome and etc.) it is ignored, rendering menu in Compact mode giving top level items crowded “too-close-for-comfort” look.
The solution is to take spacing in our own hands. Set TopItemSpacing to Compact and instead add right padding to TopLevelParentItemStyle and TopLevelLeafItemStyle elements of the menu. For example (from the markup point of view):
Actual pixel value of the padding is up to your particular scenario, but the final result is top level menu items will be nicely spaced both in IE and in Firefox.
Often, when drawing a chart, there’s a need to show a threshold – basically a line that indicates whether your values are going above or below it. Take for example this ColumnChart: