GWT CELLTABLE How to restore old value in cell if validation fails

2,321 views
Skip to first unread message

vaibhav bhalke

unread,
Aug 2, 2011, 5:59:33 AM8/2/11
to google-we...@googlegroups.com

Hi all,

PFA WebEx recording for Issue.

I want to used editableNumbercell like intger,decimal etc.. But there is no such gwt widget present so I am using editable text cell and using validation for numbers when user update value in cell.

How to avoid cell editing when validation fails.

if validation fail then editable-text cell value restored to old value.How to do that?

intgerColumn.setFieldUpdater(new FieldUpdater<RecordInfo, String>() {
       
public void update(int index, RecordInfo object, String value) {
           
// Called when the user changes the value.
           
if(value.matches("(-)?(\\d){1,8}")){
                object
.setColumnInRecordEdited(true);
                object
.setValue(value);
               
RecordData.get().refreshDisplays();
           
}else{
               
Window.alert("Specify valid integer value for parameter");
               
// How to rest old value here? currently update value set to cell

           
}

       
}
   
});

Any help or guidance in this matter would be appreciated.



--
Best Regards,
Vaibhav Bhalke
About me : http://about.me/vaibhavbhalke





Issue1-How to restore old value in cell (if validation fails).wrf

Adolfo Panizo Touzon

unread,
Aug 2, 2011, 6:14:39 AM8/2/11
to google-we...@googlegroups.com
Dis you try: "object.setValue(object.getValue());" ??

2011/8/2 vaibhav bhalke <bhalke....@gmail.com>





--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
El precio es lo que pagas. El valor es lo que recibes.
Warren Buffet

Ioan Agopian

unread,
Aug 2, 2011, 8:42:32 AM8/2/11
to Google Web Toolkit
Hi Vaibhav,

You can do it like this:
// clear incorrect data
cell.clearViewData(KEY_PROVIDER.getKey(object));
cellTable.redraw();

Where cell is the TextEditCell that you're using for that column.

Regards,
Ioan
> <http://about.me/vaibhavbhalke>
>
>  Issue1-How to restore old value in cell (if validation fails).wrf
> 203KViewDownload

Adolfo Panizo Touzon

unread,
Aug 2, 2011, 11:57:21 AM8/2/11
to google-we...@googlegroups.com
Thanks!. It´s usefull for me.

2011/8/2 Ioan Agopian <ioan.a...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

vaibhav gwt

unread,
Aug 3, 2011, 5:25:39 AM8/3/11
to Google Web Toolkit
Thanks Loan :)
I can restore old value in specific cell if validation fails.

Is it possible that all column values from particular row restore to
old value ?
|| ID || Dept || Code || RNO || RCode
|| .....................................................||ZCode ||
|| 1 || CS || 001 || 3 || 030
|| .....................................................||Q1||
|| 2 || DS || 001 || 5 || 040
|| .....................................................||S1 ||

Suppose In above editable grid I changed 1st record i.e
|| 1 || CS || 001 || 3 || 030
|| .....................................................||Q1||
changed to
|| 1 || BP || 010 || 3 || 003
||.....................................................||Q1||

Is there any way to restore old object(row) values instead to clearing
cell view data for each column and redraw editable grid.

In Short revert record to old value which is selected by our checkbox
(All or selected chkbox only i.e selectionModel.isSelected(object) )

My Grid contain (2-N) column so I am asking this question ?

Ioan Agopian

unread,
Aug 3, 2011, 8:44:04 AM8/3/11
to Google Web Toolkit
No, I don't think that's possible.

But you can store all your edit cells in a list and clear them all at
once, like this:

// when setting up table columns add the edit cells to this list
List<EditTextCell> editCells = new ArrayList<EditTextCell>();
....

// clear incorrect values for the whole row
for (EditTextCell editCell : editCells)
{
editCell.clearViewData(KEY_PROVIDER.getKey(object));
}

cellTable.redraw();

Regards,
Ioan

On Aug 3, 12:25 pm, vaibhav gwt <bhalke.vaib...@gmail.com> wrote:
> Thanks Loan :)
> Icanrestoreoldvalueinspecificcellifvalidationfails.
>
> Is it possible that all column values from particular rowrestoretooldvalue?
> || ID || Dept || Code || RNO || RCode
> || .....................................................||ZCode ||
> || 1  ||  CS   || 001  ||  3      ||  030
> || .....................................................||Q1||
> || 2 ||  DS   || 001  ||  5      ||   040
> || .....................................................||S1 ||
>
> Suppose In above editable grid I changed 1st record i.e
> || 1  ||  CS   || 001  ||  3      ||  030
> || .....................................................||Q1||
> changed to
> || 1  ||  BP   || 010  ||  3      ||  003
> ||.....................................................||Q1||
>
> Is there any way torestoreoldobject(row) values instead to clearingcellview data for each column and redraw editable grid.
>
> In Short revert record tooldvaluewhich is selected by our checkbox
> (All or selected chkbox only i.e selectionModel.isSelected(object) )
>
> My Grid contain (2-N) column so I am asking this question ?
>
> On Aug 2, 5:42 pm, Ioan Agopian <ioan.agop...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hi Vaibhav,
>
> > Youcando it like this:
> > // clear incorrect data
> >cell.clearViewData(KEY_PROVIDER.getKey(object));
> > cellTable.redraw();
>
> > Wherecellis the TextEditCell that you're using for that column.
>
> > Regards,
> > Ioan
>
> > On Aug 2, 12:59 pm, vaibhav bhalke <bhalke.vaib...@gmail.com> wrote:
>
> > > Hi all,
>
> > > PFA WebEx recording for Issue.
>
> > > I want to used editableNumbercell like intger,decimal etc.. But there is no
> > > such gwt widget present so I am using editable textcelland using
> > >validationfor numbers when user updatevalueincell.
>
> > > How to avoidcellediting whenvalidationfails.
>
> > >ifvalidationfail then editable-textcellvaluerestored tooldvalue.How
> > > to do that?
>
> > > intgerColumn.setFieldUpdater(new FieldUpdater<RecordInfo, String>() {
> > >         public void update(int index, RecordInfo object, Stringvalue) {
> > >             // Called when the user changes thevalue.
> > >            if(value.matches("(-)?(\\d){1,8}")){
> > >                 object.setColumnInRecordEdited(true);
> > >                 object.setValue(value);
> > >                 RecordData.get().refreshDisplays();
> > >             }else{
> > >                 Window.alert("Specify valid integervaluefor parameter");

vaibhav gwt

unread,
Aug 9, 2011, 3:23:48 AM8/9/11
to Google Web Toolkit, vaibhav bhalke
Hi Loan,

Thanks for your solution. It works but Performance is too bad.
i.e clearing incorrect values for the whole row (say 5) takes too much
time(clearViewData+ redraw table)

Reverting N records will take too much time :(

Is there any fast way to update old row/object in celltable ?




// when setting up table columns add the edit cells to this list
List<EditTextCell> editCells = new ArrayList<EditTextCell>();
....

// clear incorrect values for the whole row
for (EditTextCell editCell : editCells)
{
editCell.clearViewData(KEY_PROVIDER.getKey(object));

}
cellTable.redraw();

Nagarajan

unread,
Dec 12, 2014, 5:15:03 AM12/12/14
to Google-We...@googlegroups.com


Hi Vaibhav,


public void update(int index, RecordInfo object, Stringvalue) {
// Called when the user changes thevalue.
if(value.matches("(-)?(\\d){1,8}")){
object.setColumnInRecordEdited(true);
object.setValue(value);
RecordData.get().refreshDisplays();
}else{
Window.alert("Specify valid integervaluefor parameter");
// How to restoldvaluehere? currently updatevalue

}
}
});

I guess you have got ur answer for this question.

I didnt get exactly identify what u did to solve this problem.

Can you provide your code snippet wat u used to clear the values,

Thank you in advance.

Regards,
Nagarajan



Ved Ratna Mehra

unread,
Jan 3, 2017, 7:03:28 PM1/3/17
to GWT Users, bhalke....@gmail.com
Its way too late but still and I think you must have already done this... Below would redraw only a single row.
dataGrid.redrawRow( rowIndexReceivedInUpdateMethod );


Reply all
Reply to author
Forward
0 new messages