Heya,
I think your problem is that you are not either:
1) clearing the grid before re-populating it
2) removing the last row after a remove has been performed
RadioButton rb = new MyRadioButton("group", radioButtonText);
rb.addClickListener(listener);
scrollBoxGrid.setWidget(i, 0, rb);
except that the last row is now 1 less than it used to be. So I would say just
invoking:
scrollBoxGrid.clear();
before populating it should do the trick ;)
Hope that helps,
//J
[email protected] wrote:
> Hi,
>
> I have a button which allows the user to remove an item from the
> system by selecting a Radio Button and pressing 'Remove'. The system
> then deletes the item from the database and updates the list of radio
> buttons i.e. it removes the radio button that was selected for
> deletion. However, I have a bug in that the system does not remove the
> radio button completely, it just moves everything below the removed
> item 'up'. For example:
>
> Item1
> Item2
> Item3
> Item4
>
> If we delete Item2, item2 disappears, it moves item3 and item4 up so
> we have a list that looks like this:
>
> Item1
> Item3
> Item4
> Item4
>
> So item4 appears twice. I need to obviously remove the bottom radio
> button when an item is deleted but im a little stuck on how to this,
> with the way I structures the code. Please can someone offer a
> soluton?
>
> Here is my code:
>
> //Remove Item
> removeItemButton.addClickListener(new ClickListener() {
> public void onClick(Widget sender) {
> boolean msg = Window.confirm("Are you sure you wish to
> remove "
> + changedRadioValue + " from the database?");
> if (msg = true){
> String removeData = "DELETE FROM
> catering.items_table WHERE
> itemName = '" + changedRadioValue + "'";
> ServerService rpc = new ServerService();
> rpc.removeItem(removeData, callback2);
> }
> }
> });
>
>
> AsyncCallback callback2 = new AsyncCallback()
> {
> public void onFailure(Throwable caught)
> {
> updateItemsRootPanel.add(new HTML("Failed:" +
> caught.getMessage()));
> }
>
> public void onSuccess(Object result)
> {
>
> Window.alert(changedRadioValue + " was successfully removed
> from the database.");
> getStatusDataFromServer();
> }
>
> };
>
>
> ClickListener listener = new ClickListener()
> {
> public void onClick(Widget sender)
> {
> changedRadioValue = MyRadioButton.getCurrentText();;
> }
> };
>
>
>
> private void getStatusDataFromServer(){
> ServerService.getInstance().getStatusData(
> new ServerStatsUpdater());
> }
>
> //inner class setting up the radio buttons
>
> class ServerStatsUpdater extends AbstractAsyncHandler
> {
> public void handleFailure(Throwable caught){
> }
> public void handleSuccess(Object result){
> ServerSQLData data = (ServerSQLData) result;
>
>
>
> for (int i = 0; i<data.itemNameArrayList.size();i++){
> radioButtonText =
> data.itemNameArrayList.get(i).toString();
> RadioButton rb = new MyRadioButton("group",
> radioButtonText);
> rb.addClickListener(listener);
>
> scrollBoxGrid.setWidget(i, 0, rb);
> }
> for (int i = 0;
> i<data.itemQuantityArrayList.size();i++){
> Label quantityInStock = new Label();
> quantityInStock.setText(" " +
> data.itemQuantityArrayList.get(i).toString());
>
> scrollBoxGrid.setWidget(i, 2, quantityInStock);
> }
>
> }
> }
>
>
>
> Any help much appreciated.
>
> Regards,
> Jack
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---