I'm trying to format a Ultragridcell using the following code and it works fine.
//Code
DefaultEditorOwnerSettings editorSettings;
DateTimeEditor datetime_editor;
editorSettings = new DefaultEditorOwnerSettings()
editorSettings.DataType = typeof(DateTime);
editorSettings.MaskInput = "mm/dd/yyyy";
datetime_editor = new DateTimeEditor(new DefaultEditorOwner(editorSettings));
e.Row.Cells["DateInfo"].Editor = datetime_editor;
But when I try to format like the below code, it fails.
//Code
DefaultEditorOwnerSettings editorSettings;
DateTimeEditor datetime_editor;
editorSettings = new DefaultEditorOwnerSettings()
editorSettings.DataType = typeof(DateTime);
editorSettings.MaskInput = "D";
datetime_editor = new DateTimeEditor(new DefaultEditorOwner(editorSettings));
e.Row.Cells["DateInfo"].Editor = datetime_editor;
Is that only the custom formatting that too only limited types works with the cell or i'm wrong somewhere.
Need an advice on this.
It seems that you think that MaskInput property supports all the formatting functionality provided by Composite Formatting, but I don't think that it is true.
The formatting available for MaskInput as far as I know are limited to only these provided by the UltraGrid Designer.
Using the UltraGrid Designer (right click on the UltraGrid control, select UltraGrid Designer) click on the Data Schema and define a data schema in which one of the columns will be a DateTime column. Then go to the Bands and Column Settings node, select columns and then the column defined as DateTime. In the properties window you can find the MaskInput property and its allowed values. You could try to experiment with the predefined masks and check if there is one that fits your requirements.
As I have said this is what I suppose to be true. I don't know if there is another advanced mode to set these properties at design time or at Runtime. If, someone from Infragistics, wants to add something to this answer would be welcome
Related
I am Using a Script Adapter by passing payload to get contend for a Content List from "Search with values" event
When Contend get loaded to content list , i have a custom view to preview them. But if i clicked on MIME type column , It opens a separate view with the mapped viewer
So I need to remove this column or make it un-clickable
1) I am passing search values to content list's "Search with values" event , from where can i handle Content List's contend loading ,any Dojo Event i can use ?
2) With Script Adapter can i do this without going for a "response filter"
Edit :
As Nicely explained by "Ivo Jonker" (in his answer - "or try to specifically locate the widgets on your page" and with his example code)
responsed = page.ContentList8.ecmContentList.getResultSet();
var cols = responsed.structure.cells[0];
for (i=cols.length-1; i>0; i--){
var col = cols[i];
if (col.field=="mimeTypeIcon")
cols.splice(i,1);
}
page.ContentList78.ecmContentList.setResultSet(responsed);
I simply remove this row. Thanks Again and lovely blog , hope you keep posting more great articles.
The values passed through the Search With Values event will eventually be handled by the icm.pgwidget.contentlist.dijit.DocumentSearchHandler
that in turn creates a SearchTemplate to execute the search (ecm.model.SearchTemplate.prototype.search). One option would be to aspect/before/around the DocumentSearchHandler#query to manipulat the searchresults and by that way to remove the column.
The wiring however does not provide any handles to achieve this for a specific query-resultset combination leaving you to either fix this on a global scale (icm.pgwidget.contentlist.dijit.DocumentSearchHandler.prototype#query), or try to specifically locate the widgets on your page.
Personally, taking into account #2, i'd go for the responsefilter-option if you feel the global solution wouldn't be a problem, or alternatively i'd personally prefer to create a simple ICM widget that instantiates/implements a "plain" ecm.widget.listView.ContentList and exposes a wire to set the ecm.model.Resultset.
You'd then be able to create your own Searchquery in a scriptadapter, remove the column, and pass the resultset.
The script adapter could be something like:
var scriptadapter=this;
var queryParams={};
queryParams.query = "SELECT * FROM Document where id in /*your list*/";
queryParams.retrieveAllVersions = false;
queryParams.retrieveLatestVersion = true;
queryParams.repository = ecm.model.desktop.repositories[0];
queryParams.resultsDisplay = {
"sortBy": "{NAME}",
"sortAsc": true,
"columns": ["{NAME}"],
"honorNameProperty": true};
var searchQuery = new ecm.model.SearchQuery(queryParams);
searchQuery.search(function(response/*ecm.model.Resultset*/){
//remove the mimeTypeIcon
var cols = response.structure.cells[0];
for (i=cols.length-1; i>0; i--){
var col = cols[i];
if (col.field=="mimeTypeIcon")
cols.splice(i,1);
}
//emit the resultset to your new contentlist, be sure to block the regular synchrounous output of the scriptadapter
scriptadapter.onPublishEvent("icm.SendEventPayload",response);
//The contentlist wire would simply do contentlist.setResultSet(response);
});
i want to make a variable can be used in .caption, so i can get the value and used it to make something.
last experiment, i use it in foxpro and it can work pretty well.
like this.
foxpro code mix variable with system
tmbl = "command"+alltrim(str(i)) set order to no_room seek
(thisform.pageframe1.page1.&tmbl..caption
see the &tmbl.?? im using it as a connector to .caption
now im trying to do it in VB.NET. it can not work. i don't know what kind connector must be use in VB.NET. so can somebody please tell what must to use in VB.NET?
You can simply use controls collection to find the control you want (and even in VFP it is the way to go, instead of abusing the & operator). Say you want to do this for a label, in C# it looks like:
var label = this.Controls.OfType<Label>()
.SingleOrDefault(c => c.Name == "command" + i);
if (label != null)
{
label.Text = "Whatever";
}
Telerik code converter converts this to VB.Net as:
Dim label = Me.Controls.OfType(Of Label)().SingleOrDefault(Function(c) c.Name = "command" + i)
If label IsNot Nothing Then
label.Text = "Whatever"
End If
I have a Master-Detail set up with 2 grids. On the master grid, I have the ShowOnlyPredefinedDetails option set to false.
This means that I see a little + sign that allows me to expand the details of the detail grid (in the master grid). I would like to rename
some columns in that section as well as hide certain columns. I'm using VB.NET How do I go about this. See image.
You can accomplish this by using the grid control ViewRegistered event, from there you can modify the columns in that grid view that have columns within them that you want to modify, rename, or remove. Here is an example, I hope that it helps:
private void myGridControl_ViewRegistered(object sender, DevExpress.XtraGrid.ViewOperationEventArgs e)
{
if (e != null)
{
if (e.View != null)
{
//Inside of this statement you can adjust, add, and modify all of the columns inside of that grid that appears when you click on the +
(e.View as GridView).Columns["myHiddenColumn"].Visible = false;
(e.View as GridView).Columns.Add(new GridColumn() { Name = "AddColumn", Caption = "Name To Display", Visible = true, FieldName = "DataField"});
(e.View as GridView).Columns["DataField"].OptionsColumn.AllowEdit = false;
(e.View as GridView).Columns["DataField"].OptionsColumn.AllowFocus = false;
(e.View as GridView).Columns["DataField"].OptionsColumn.ReadOnly = true;
}
}
}
I think all you need to do is create a second grid view for your details. If you haven't already done this, do the following:
In your grid designer, click "Retrieve Details" if you have not already done so. This will cause the designer to recognize that you have a second level in your bound object:
Once you see the second layer, now you need a new grid view for it. Click on "Click here to change view" and select "Create a new view" and pick "GridView."
Now you will see both grid views from the designer, and clicking on one or the other will change the context of the menus to the left:
For example, if you have gridView2 selected, when you click on the "Layout" menu, it will show the current layout for your detail grid rather than the master grid. From here, you can remove or add columns as you see fit. Likewise, from the "Columns" menu you will see the new columns (you may have to add them to the view by dragging them over), and you can change the Caption property to change the text of the title.
I suggest you use the Data Annotation attributes with properties of your data-classes to declare how you data should be displayed in GridControl:
To skip column generation for the specific property you can mark this property with the <DisplayAttribute(AutoGenerateField := false)> declaration.
To prevent column from displaying you can mark this property with the <DisplayAttribute(Order := -1)> declaration. Later, user can show this column via Column Chooser UI.
To specify the column caption use the <DisplayAttribute(Name := "YOUR CAPTION")> declaration.
You can also control filtering/editing/formatting and validation capabilities.
Related Links:
Tutorial: Create and Manage Data in Code and Apply Data Annotation Attributes
Video Tutorial: Create and Manage Data in Code and Apply Data Annotation Attributes
I need to format the cell of an UltraGrid.
Like: Making the cell to format a DateTime.
I have done for a column,
UltraGridColumn.Format = "d"
likewise is there any option to format individual cells?
UltraGridRow.Cells("abc")= ?
Note: Using the Infragistics version 12.1
The trick to force the UltraGrid to use different editors for cells in the same column is based on a set of programming objects and patterns offered by the infrastructure of the control.
The first thing is to consider is the InitializeRow event. This event is called for each row when you set the initial DataSource of the grid or when you change something in the underlying DataSource. You can differentiate between the two situations thanks to the e.Reinitialize flag. If it is false, then the whole datasource is applied to the grid, if it is true then only a subset of rows are reinitialized usually because the user has edited the cell or the code has changed a value in the datasource.
The second thing to consider is the Editor property present in every UltraGridCell or UltraGridColumn. It is an object that is built automatically by the UltraGrid to allow the cell editing. The UltraGrid code set this object based on the datatype of the column and, obviously, sets the same editor for every cell of the column. You could set your own editor at the column level (usually in the InitializeLayout event) or on cell by cell basis looking at your formatting rule.
Let's try an example (Big parts of this is taken from the example code suggested in its comments by Alhalama)
Suppose you have a DataTable with only two columns:
First column is called CONDITION and contains a string. This string is my formatting requirement.
The second column is called DATEINFO and contains the dates that should be formatted differently accordingly to the value in the column CONDITION.
So if CONDITION = 'TEST1' then the DATEINFO cell is formatted with Day/Month/Year pattern, if the CONDITION='TEST2' then the DATEINFO cell should be formatted with Hour/Minute/Seconds.
private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
{
if (e.ReInitialize == false)
{
DefaultEditorOwnerSettings editorSettings;
DateTimeEditor datetime_editor;
string condition = e.Row.GetCellValue("Condition").ToString();
switch (condition)
{
case "TEST1":
editorSettings = new DefaultEditorOwnerSettings()
editorSettings.DataType = typeof(DateTime);
editorSettings.MaskInput = "mm/dd/yyyy";
datetime_editor = new DateTimeEditor(new DefaultEditorOwner(editorSettings));
e.Row.Cells["DateInfo"].Editor = datetime_editor;
break;
case "TEST2":
editorSettings = new DefaultEditorOwnerSettings()
editorSettings.DataType = typeof(DateTime);
editorSettings.MaskInput = "hh:mm:ss";
datetime_editor = new DateTimeEditor(new DefaultEditorOwner(editorSettings));
e.Row.Cells["DateInfo"].Editor = datetime_editor;
break;
}
}
}
I'm using an Infragistics UltraWinGrid and would like to be able to display the sum of several columns. I got that working by allowing row summaries. However, I only want them to be able to see the sum, not have all these other crazy options that come along with that little sigma in the header. How can I get rid of this while keeping the sums at the bottom?
You should have the DisplayLayout.Override.AllowRowSummaries property set in this way:
DisplayLayout.Override.AllowRowSummaries = AllowRowSummaries.Default;
then use code like this to create your summary
(Need to check before creating another summary with the same name)
private void BuildCurrencySummary(string name, UltraGridColumn col)
{
SummarySettings ss = grd.DisplayLayout.Bands[0].Summaries.Add(name, SummaryType.Sum, col);
ss.SummaryPositionColumn = col;
ss.SummaryPosition = SummaryPosition.UseSummaryPositionColumn;
ss.Appearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True;
ss.Appearance.ForeColor = Color.Black;
ss.Appearance.TextHAlign = HAlign.Right;
ss.DisplayFormat = "{0:C}";
}
From Infragistics Forum :
You can still apply summaries to a column without setting the AllowRowSummaries property.
The purpose of the AllowRowSummaries is to show (or not show) the interface for the user to establish their own summaries. This is the "sigma" symbol you were seeing.
From the Override object, set the AllowRowSummaries property to False.
UltraGrid1.DisplayLayout.Override.AllowRowSummaries = Infragistics.Win.UltraWinGrid.AllowRowSummaries.[False]