Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » NatTable : Table level validations(How to validate all the rows in a NatTable grid upon a button click.)
NatTable : Table level validations [message #1278693] Thu, 27 March 2014 18:16 Go to next message
pawan kalyan kalyan is currently offline pawan kalyan kalyanFriend
Messages: 3
Registered: March 2014
Junior Member
I need to implement some table level validations for a NatTable grid. I am able to validate individual cells using "org.eclipse.nebula.widgets.nattable.data.validate.DataValidator" and I could do it only for text boxes using TextCellEditor (I could also highlight the cells by setting errorDecorationText for the text boxes which have validation errors).

Similarly, I need to validate certain combo boxes (drop down boxes) in a NatTable grid but not at a Cell level but at a table level. (like upon a button click, where there exists a button underneath a NatTable grid), Also, I need to highlight the combo box cells which have validation errors. Can somebody post any suggestions ?
Please let me know if you need more information.

Thanks,
Pavan Kalyan.
Re: NatTable : Table level validations [message #1278808 is a reply to message #1278693] Thu, 27 March 2014 22:01 Go to previous messageGo to next message
John Steele is currently offline John SteeleFriend
Messages: 50
Registered: January 2010
Member
Hi Pavan,

You need to attach a label to the cells that have validation errors, and then register a Style (perhaps with a background color or red/pink) under that same label.

Here's how you register the style:

public static final String CELL_ERROR = "invalid";
configRegistry.registerConfigAttribute(
			CellConfigAttributes.CELL_STYLE, 
			style, 
			DisplayMode.NORMAL, 
			CELL_ERROR);


You might also want to have a label accumulator, which will add the CELL_ERROR label to the cells that have an error.

Here's how you might do that:

natTableBodyDataLayer.setConfigLabelAccumulator(new IConfigLabelAccumulator() {
            @Override
            public void accumulateConfigLabels(LabelStack configLabels,
                    int columnPosition, int rowPosition) {
                    if (errorExistsOnCell (columnPosition, rowPosition)) {
			configLabels.addLabelOnTop(CELL_ERROR);
		    }
                }
            }
        });


Cheers!
Re: NatTable : Table level validations [message #1279062 is a reply to message #1278808] Fri, 28 March 2014 07:32 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Hi,

the above explanation is correct. What you need is some kind of weak validation, as hard validation will not allow to commit a value to the data model.

I wrote a blog post about this a while ago: http://blog.vogella.com/2013/03/02/crossweak-validation-in-nattable-by-dirk-fauth/

Greez,
Dirk
Re: NatTable : Table level validations [message #1464263 is a reply to message #1279062] Fri, 07 November 2014 11:08 Go to previous messageGo to next message
ambuj bhargava is currently offline ambuj bhargavaFriend
Messages: 19
Registered: July 2014
Junior Member
Hi

I am able to use the validation on the cell.
I am using it in the way it is being used in the cross validation example by you.

class EventDataValidator extends DataValidator {
private IRowDataProvider bodyDataProvider;

EventDataValidator(IRowDataProvider bodyDataProvider) {
this.bodyDataProvider = bodyDataProvider;
}

@Override
public boolean validate(int columnIndex, int rowIndex, Object newValue) {

}


Here the problem I am facing is on clicking enter after the cell value is entered, the error message is not invoked immediately.
When I start entering the value in the new cell it gets invoked .

Can you please help
Re: NatTable : Table level validations [message #1464298 is a reply to message #1464263] Fri, 07 November 2014 11:58 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Have a look at _4451_CrossValidationGridExample in the NatTable example application. Maybe there is some mistake in the blog post that has been fixed there
Previous Topic:NatTable Auto Focus functionality
Next Topic:Minimum number of rows visible
Goto Forum:
  


Current Time: Fri Mar 29 02:09:50 GMT 2024

Powered by FUDForum. Page generated in 0.02578 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top