How to set the Focus on Particular Cell in UI Grid - angular-ui-grid

I have a situation where, if I edit Cell1, UI Grid will run validators for Cell1, but I also want to run the validators for Cell2.
If Cell2 value is not proper then I want to set focus on Cell2 with validation message set in uiGridValidateService.setValidator().
I am able to run the validator for Cell2 on Cell1 edit using below statement, but not able to highlight Cell2.
Code:
gridApi.grid.validate.runValidators(rowEntity, colDef, rowEntity['Cell2'], NaN, $scope.gridApi.grid);
How can I put focus on a particular cell in UI Grid?

I solved it by below, hope it will help someone with same requirement,
Rather than trying to set the focus on error field, I just added below code on afterCellEdit().
if (!rowEntity['$$errors' + fieldName]) {
rowEntity['$$errors' + fieldName] = {};
}
rowEntity['$$errors' + fieldName][validatorName] = true;
rowEntity['$$invalid' + fieldName] = true;
Where my fieldName is target field which I want to get validated on every cellEdit. So in my case, even if I am editing value of Cell1, I will pass fieldName='Cell2' and it will get validated against my validator that I will pass as 'validatorName'. If it is not proper value then it will highlight cell2 as red and will show its tooltip.
Hope it will help someone. Let me know if any questions.

Related

If cell is blank preform formula else use value

I'm trying to conditionally set the value of a cell if there isn't already a value in it. I want to use a separate column so as to not lose the formula if a value is put in. This is what I'm trying. It's just saying FALSE in the cell
=IF(ISBLANK(D2),D2=FILTER(Characters!G3:G9,Characters!B3:B9 = B2))
Remove D2=
=IF(ISBLANK(D2),FILTER(Characters!G3:G9,Characters!B3:B9 = B2))

Change color of readonly cells using angular ui-grid

I am using Angular UI Grid for ui-grid in my project
I want to make some cells read only.
cellEditableCondition(for row) and enableCellEdit (for column), I am able to achieve it. This is working fine.
But Now I want to change color of all Cells which are readonly just after page load, How can I achieve this.
I understand cellEditableCondition field only execute when user click on cell in grid.
any pointer also appreciated.
I used cellClass in columnDef to achieve this
its working perfectly fine
cellClass: function (grid, row) {
if(myCondition){
return 'test-class1';
}else{
return 'test-class2';
}
},

Spreadsheet gear cell with list validation selection changed event?

I have list validation on a few cells and would like to shade the cell if a value is selected/changed from dropdown(filter list). For regular cells, I use EndEdit event which apparently doesn't fire in this case.
Could anyone please point me to right event to do this?
Thanks in advance!
There is no specific event that fires for a cell validation dropdown selection action. The WorkbookView.CellEndEdit event is solely used for "edit mode"--when a user manually types some value into a cell--and there is nothing in SpreadsheetGear API to expand edit mode to include other forms of input.
The WorkbookView.RangeChanged event will fire whenever a change is made to a cell, including via a cell validation listbox; however, many other actions trigger this event as well, such as changing a cell's NumberFormat, font formats, etc; or inputting a cell value in some other way such as pasting a value, FillDown, Clear, etc. Still, you may be able to use this event to, within some reasonable assurance, get the information you need.
Below is some sample code that demonstrates how you could detect whether RangeChanged was called from a single cell containing cell validation. Additional conditions are used to ensure to the best of our ability that the event was triggered by the user changing a value via the validation dropdown list. Again, this still isn't 100% foolproof for the reasons listed above.
private void workbookView_RangeChanged(object sender, SpreadsheetGear.Windows.Controls.RangeChangedEventArgs e)
{
// Did this RangeChanged action affect only a single cell?
if(e.Range.CellCount == 1)
{
IRange cell = e.Range;
// Does the cell even have cell validation?
if(cell.HasValidation)
{
IValidation validation = e.Range.Validation;
// Is the validation applied to this cell of the "List" type and
// does the inputted value pass validation checks?
if(validation.Type == ValidationType.List && validation.Value)
{
// Do something here, such as shade the cell...
cell.Interior.Color = SpreadsheetGear.Colors.LightGray;
}
}
}
}
Please see the documentation for the IValidation interface members for more information on each of the properties used above.

Getting values out of text fields with UIAutomation

I'm trying to understand how UIAutomation can be used to perform automatic application tests, so I've created a temperature converter app that can be driven from the JavaScript interface. Here's the UI:
The top text field has an Accessibility label of "Celsius", similarly the bottom field has "Fahrenheit" as its Accessibility label. I'm trying to drive it through this script:
UIALogger.logStart("Test -40ºC == -40ºF");
var window = UIATarget.localTarget().frontMostApp().mainWindow();
var celsiusField = window.textFields()["Celsius"];
var fahrenheitField = window.textFields()["Fahrenheit"];
var convertButton = window.buttons()["Convert"];
celsiusField.setValue("-40");
convertButton.tap();
var fahrenheitValue = fahrenheitField.value();
if (fahrenheitValue == "-40.0") {
UIALogger.logPass("-40C == -40F");
} else {
UIALogger.logFail("-40C == " + fahrenheitValue + "F");
}
This correctly sets the text in the Celsius field to "-40", and when the button is tapped, the app updates the text in the Fahrenheit field to "-40.0". However, fahrenheitValue has the value "Fahrenheit" (the name/label of the text field), so the test fails. I wondered whether this was maybe a timing issue, so put in a one-second delay after the tap, which didn't change the behaviour.
Is it possible to get the text out of the text field and compare it with the expected value?
Is it getting "Fahrenheit" because that's the accessibility label or because it's the placeholder text?
It looks like value() might return the placeholder text. One workaround could be to modify the placeholder value once the user starts typing to set it to be the text the user entered and then reverting it to Fahrenheit when they delete? I assume that even when you call setValue it acts as it would when the UITextField delegate methods get called?
You could add a label to your view, update it and read it out.
Try hooking up the Accessibility Inspector to show what UIAutomation "sees" in your app. It might be that it's reading some stale values because of the way you set the values in your app.
One way of refreshing the values is to send an update event:
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);

GridPanel cell editing of type 'textfield'

I'm using a GridPanel with the 'CellEditing' plugin.
My editor cell is of type 'textfield'.
I have 2 questions:
I would like to change the background color of empty cells so that it would be easier to see where there are missing values.
When double clicking a cell, I would like to format the text of the textfield. How do I get to the textfield object?
Thank you,
Dana
You might give the textfield an id property.
field: {
id: 'myId',
...
}
Access the field with
var objTextfield = Ext.getCmp('myId');
About the color, you must add or overwrite the CSS. You can set a config property 'cls' to a custom css class. See here: http://docs.sencha.com/ext-js/4-0/#/api/Ext.form.field.Text-cfg-cls

Resources