How to prevent a user from changing the selected row in an EditorGrid - gxt

Is there a way that I can prevent a user from changing the selected row? I was looking for something like a selectedRowChanging event that would either prevent or allow user from selecting a new row.

Kinda depends on how you have things set up...
I have a Grid to which I've added a CheckColumnConfig and RowEditor It's really a window into some DataBase tables. The user can modify any column 'except' the key columns. The user may also Add a new row. I defined 2 ColumConfigs. The EditColumnConfig has the various fileds disabled (i.e. if (column = keyColumn) {textField.disabled(); } the AddColumnConfig has all columns enabled.
Now if the user clicks the checkBox on a row and clicks an 'Add' button I reconfigure the grid with the addColumnModel : rowDataGrid.reconfigure(listStore, addStateColumnModel); When the user clicks the RowEditor 'Save' button I erconfigure the grid back : rowDataGrid.reconfigure(listStore, editStateColumnModel);
I 'spose you could define an uneditable ColumnConfig and swap it in and out. (or... catch the RowEditor 'BeforeEdit' event and disable to row).
That's an idea anyway... hope this helps.

grid.addListener(Events.BeforeEdit, new Listener<GridEvent<MyModel>>(){
#Override
public void handleEvent(GridEvent<MyModel> be) {
//This retrieves the model being edited.
MyModel model = be.getModel();
if (I do not want to edit this model){
be.setCancelled(true);
}
}
});

Related

Label gets selected on clicking enter key in the tabulator cell

I have a js fiddle to show the issue that I am facing.
Tabulator 'email' column has freetext set to true to allow the user to set the value of the cell to a free text entry as follows:
editorParams:{
values:{
"steve#boberson.com":"steve",
"bob#jimmerson.com":"bob",
"jim#stevenson.com":"jim",
"harvy#david.com":"Harvy",
"ken#thompson.com":"Ken",
"denny#beckham.com":"Denny"
},
freetext:true,
searchFunc:function(term, values){
console.log("term and val "+term +" \n"+values);
var matchedEntries = {};
var matchFound = false;
for(var key in values) {
if(key.includes(term)){
matchFound = true;
matchedEntries[key] = values[key];
}
}
if(matchFound){
return matchedEntries;
}
else{
return {term: term};
}
}
}}
Select one of the values from the selector list displayed, say steve, value being 'steve#bobberson.com'.
Then after the value is selected, click on the same tabulator cell, the value displayed suddenly changes to the label.When user clicks enter key now, the label is selected instead of the value,.ie. steve will be displayed instead of steve#bobberson.com
If this is not a bug, how do I make sure that the value steve#bobberson.com remains selected after clicking enter. This is because freetext option is set to true in the editorParams of the column
Attached a gif showing the issue
That is not a bug,
With freetext enabled, users are able to enter any text they like in that field and it will be saved which is exactly what is happening in the example
If they select the email address again from the list then it is correctly saved.
It is an either/or scenario, you can either restrict the users to selecting specific values from the list OR you can allow them freetext in which case anything goes.
If you want a different behaviour then you can always build a custom editor that works in the way you want. Checkout the Custom Editor Documentation for more information

Trying to customize JAMS LaborEntry screen, looking for the line of code that will update the header

Brand new to Acumatica development and stuck on a simple thing. :(
I am customizing the LaborEntry screen of the JAMS MFG.
I have added a field to the header by extending the AMBatch DAC, called UsrTimeClocked.
For now I simply wish to set this field to a number right at the end of the RowInserted event at the detail level of the AMMTran and see my number on the screen, up on the header AMBatch.
public class LaborEntry_Extension : PXGraphExtension<LaborEntry>
{
protected virtual void _(Events.RowInserted<AMMTran> e)
{
AMBatchExt ext = Base.batch.Current.GetExtension<AMBatchExt>();
ext.UsrTimeClocked = 5.32;
//Insert line to update the correct object to see 5.32 in the TextBox, before RowSelected is done.
}
}
As is my value goes in the field and any refresh/save/delete of the row does update the correct object and I see my value where I want it. I wish to know the way to force this update.

TestFx - How to test validation dialogs with no ids

I have an application with grid of records and button insert. After clicking insert, there is a form, where you fill in data and click Ok for adding new record to the grid. After clicking Ok, there is validation which fires dialog with error informations, if any of the text fields do not match validation rules. Is there any posible way to test text on the dialog with textFx, if the dialog has no id?
This is an example for Alert based dialog:
In your test:
alert_dialog_has_header_and_content(
"Removing 'Almaty' location", "Are you sure to remove this record?");
In you helper test class:
public void alert_dialog_has_header_and_content(final String expectedHeader, final String expectedContent) {
final javafx.stage.Stage actualAlertDialog = getTopModalStage();
assertNotNull(actualAlertDialog);
final DialogPane dialogPane = (DialogPane) actualAlertDialog.getScene().getRoot();
assertEquals(expectedHeader, dialogPane.getHeaderText());
assertEquals(expectedContent, dialogPane.getContentText());
}
private javafx.stage.Stage getTopModalStage() {
// Get a list of windows but ordered from top[0] to bottom[n] ones.
// It is needed to get the first found modal window.
final List<Window> allWindows = new ArrayList<>(robot.robotContext().getWindowFinder().listWindows());
Collections.reverse(allWindows);
return (javafx.stage.Stage) allWindows
.stream()
.filter(window -> window instanceof javafx.stage.Stage)
.filter(window -> ((javafx.stage.Stage) window).getModality() == Modality.APPLICATION_MODAL)
.findFirst()
.orElse(null);
}
I know this issue is a little old and probably got fixed, but for documentation purpose in case someone else look for a fix for an issue alike, I see dialog.getDialogPane() in Dialog documentation, which would help lookup for specific controls inside the pane. So further on #plaidshirt query, we could retrieve buttons and input fields with:
dialog.getDialogPane().lookupAll()
Then narrow that down to buttons and input fields for example.

Custom selector challenges

I have a custom screen with a multiple custom selectors, which change what they select based on dropdown lists.
The solution I implemented is shown in a previous case:
Dynamically changing PXSelector in Acumatica (thanks).
My challenge is twofold:
1.) If the dropdown selection is "No Lookup", then I want the PXSelector Attribute to essentially be removed - leaving just a text entry. Not sure if this is even possible...
2.) If one of the selectors (let's say Projects) is selected, I'd like the selection of the following selector (let's say Tasks) to filter based on the Project selected.
Thanks much...
1) I think the only way to do this is to create your own attribute.
Something like that:
public class PXSelectorTextEditAttribute : PXSelectorAttribute
{
bool selectorMode;
public PXSelectorTextEditAttribute(Type type, bool selectorOn):base(type)
{
selectorMode = selectorOn;
}
public override void FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
{
if(selectorMode)
base.FieldVerifying(sender, e);
}
public static void SwitchSelectorMode(PXSelectorTextEditAttribute attribute, bool onOff)
{
attribute.selectorMode = onOff;
}
}
You will be able to turn on and off the 'selector' part of the attribute. With the field verifying turned off you will be able to put any value to the field just like in simple TextEdit field. However, the lookup button in the right end of the field still will be visible. I have no idea how to hide it.
2) This behavior can be implemented easily. You will need something like that(example based on cashaccount):
[PXSelector(typeof(Search<CABankTran.tranID, Where<CABankTran.cashAccountID, Equal<Current<Filter.cashAccountID>>>>))]
If you want to see all records when the cashaccount is not defined then you just modify the where clause by adding Or<Current<Filter.cashAccountID>, isNull>
Also don't forget to add AutoRefresh="true" to the PXSelector in the aspx. Without it your selector will keep the list of the records untill you press refresh inside of it.

Dynamically Selection of items in combobox

i want to add some functionality in combo box. I want that it should behave like Google's Search Box. Like i have added items in combo box from a database Say Name of the Doctors.
i want that as user type name of the doctor or first letter of the name of the doctor, the selection bar goes automatically only to related names.
Any suggestion friends???
try AutoCompleteMode of combobox, something like this:
сomboBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
сomboBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
comboBox.AutoCompleteCustomSource = MyStringData();
where myStringData is :
public AutoCompleteStringCollection MyStringData()
{
var collection= new AutoCompleteStringCollection();
//you can add names of the doctors retrieved from the database here
collection.Add("one");
collection.Add("two");
collection.Add("three");
collection.Add("four");
return collection;
}
this would suggest those items which begins with those you typed.
If you want to show selection (highlighting) as you type, you can be a little more creative and create a simple combination of a textbox and gridView, which gets bound everytime TextChanged happens on the textBox

Resources