changing the color of one cell in a datagrid after grid was startet - dojo

I have problems to change one cell of a datagrid after the grid is started. I want to change the colour of some cells and I need to ask if this cell has another value as a cell in another column, and then if this is true to change the colour.
How can i do this?

Try
var rows = dojo.query(".dojoxGridRow", grid.domNode);
var cellsInSecondRow = dojo.query("td", rows[1]);
var cellTwoInSecondRow = = dojo.query("td[idx='1']", rows[1]);
etc..

Related

Format UltragridRow Cells

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;
}
}
}

How do I get the parent row index from a grid cell in Extjs?

I have a CheckColumn in a GridPanel and I want to disable the editable cells of a given row if the checkbox on that row has been checked. Is this possible?
The easiest way to do this is to listen to the beforeedit event on the editor. Something like:
cellEditing.on('beforeedit', function(ed, context) {
return !context.record.get('checkField');
});

How can I show a summary in the footer of a win grid and not have the Sigma show up in the header?

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]

How to change font color of a dojo DataGrid row after a cell has been edited

I want to change the font color of a row after a cell in that row has been edited and set to a certain value.
myStore is the dojo.data.ItemFileWriteStore associated to the dojox.grid.DataGrid dataGrid.
I have written this:
myStore.onSet = function(item, attribute, oldValue, newValue) {
if (item.myField == myValue) {
var index = dataGrid.selection.selectedIndex;
dojo.style(dataGrid.getRowNode(index), "color" , "red");
}
}
but unfortunately this doesn't make any effect...
UPDATE: I added the following style property: "backgroundColor" : "red". Well, the background color of the row changes to red, but when the mouse moves away from the row, the color changes back to the default! It might be that some default event handlers restore the default styles...
The dojo.style line works if you call it by itself. Either your function isn't being called at all, the if's condition false or there is no row selected and you are getting an invalid number for the index. (You can put some console.logs there to check)

How to hide the column header for a Devexpress GridLookUpEdit?

I currently have a DevExpress GridControl where one of the columns have a GridLookUpEdit assigned under ColumnEdit. Yet when I run there is a column name (the display member) that shows up.
I know with a LookUpEdit you can set the column headers to invisible with lookupedit.Properties.ShowHeader = False but I have no clue how to make it invisible for the GridLookUpEdit.
Use:
lookupedit.Properties.View.OptionsView.ShowColumnHeaders = False
Use the following code to hide a column:
gridLookUpEdit1.Properties.View.Columns("SomeFieldName").Visible = false
What you do is run the property editor, go to columns and select the column that your lookupedit is assigned to. Then expand your column edit, then the view within, then the OptionsView. Then set ShowColumnHeaders to false. This will set all of the column headers within the lookupedit to false.
For devexpress 18.2.8
I'm using the following code to hide a column:
using (DataTable dt = rst.ResultSet.Tables[0].Copy())
{
dt.Columns["Unit_ID"].ColumnMapping = MappingType.Hidden;
ddlUnitOfMeasurement.Properties.DataSource = dt.DefaultView;
ddlUnitOfMeasurement.Properties.ValueMember = "Unit_ID";
ddlUnitOfMeasurement.Properties.DisplayMember = "Unit_Name";
}