Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

  • Blama
    replied
    Hi mathias,

    I'm doing a similar thing to yours and am facing other problems I'm trying to solve.

    My problem is that the callbacks at hand are called directly on drag/drop, not after the datasource actually adds/removes.
    Isn't it possible to move your custom logic from the CallBack of the drag/drop to the CallBack of your (custom called) DSOperation?

    but if i do the remove myself in order do be able to define the execute method and act on the dsresponse, i get two calls, since smartgwt also issues an automatic remove.
    I'm facing this, too, and am trying to solve with:
    Code:
    addRemoveRecordClickHandler(new RemoveRecordClickHandler() {
    	@Override
    	public void onRemoveRecordClick(RemoveRecordClickEvent event) {
    		final ListGridRecord record = assignedProductsGrid.getRecord(event.getRowNum());
    		leadProductAssignedDS.performCustomOperation("removeProduct", record);
    		// Disable default behavior (meaning a remove request)
    		event.cancel();
    	}
    });
    Don't know if it will work. Did you see the Docs for ListGrid.addRemoveRecordClickHandler#event.cancel()?

    Best regards,
    Blama

    Leave a comment:


  • mathias
    replied
    Hi, would be great to get a response from you guys, so i'll try and re-phrase.

    I want, like in your example, use callbacks to add and remove from the "origin" listgrid" to only show those that have not been added to the group yet.

    My problem is that the callbacks at hand are called directly on drag/drop, not after the datasource actually adds/removes. For example:

    If I add a "addrecorddrophandler" it is called right away, before my server spring service is called, so if i add the logic there to remove the row from the "source" grid, i could end up with a situation where the record is removed, my server is called and can't actually add the record to the group, but the record has been removed anyway.

    >>> I need callbacks so that i can act when the *data operations on the datasource* (i.e. add/remove) has returned with a successful dsresponse from the server call.

    As i mentioned above, for remove i seem to be able to do that, but if i do the remove myself in order do be able to define the execute method and act on the dsresponse, i get two calls, since smartgwt also issues an automatic remove.


    Pointers much appreciated.

    Leave a comment:


  • mathias
    replied
    Right,

    1. What i meant was that in your example, you do the actual add-server call yourself in the recordclickhandler:

    Code:
    teamMembersGrid.removeData(record, new DSCallback()
    and then handle the 'mock add' in the DSResponse callback.
    This is great, and what i attempted too.

    But when i attempt this myself, with my datasource where i have defined a spring service in the XML, the "remove" method in my spring bean gets called twice!

    My guess was that it is once because of my "removedata" call, and then again because you have some internal clickhandler as a result of the
    Code:
    teamMembersGrid.setCanRemoveRecords(true);
    that also ends upp calling my service whether i added my own handler or not. Hence my comment about the method being called "ADDRemoveRecordClickHandler" rather than "SETRemoveRecordClickHandler". If i handle the remove-call myself, as you also do in your example, i do not want another handler to do it as well.

    i hope you follow.


    2. I just meant that in the discussion above i have access to the DSresponse and can act on it, but in the add process, i don't perform the actual DSRequest add calls, they happen as part of your listgrid automatic logic, so i don't have access to the dsresponse. Therefor, if i for example only want to do the "updatecaches" if everything went ok server-side, i can't see how i would do that. Or is the "onrecorddropped" called after the server call and only if everything went ok?

    Leave a comment:


  • Isomorphic
    replied
    1. don't really follow this question. If you've implemented a DMI, you can obviously do whatever you want, of course..

    2. we're not sure what errors you're worried about, but there is built-in error handling if you signal that the save failed, and you can read the Error Handling overview for various ways of customize responding what happens. You can also take a look at recordsDropped, which explains how you could replicate the built-in drop functionality if you wanted to manually handle the whole thing.

    Leave a comment:


  • mathias
    replied
    Thanks, exactly what i was after!

    I have a couple of follow-up questions, though:


    1. in the example, you do a "addremoverecordclickhandler", to manually do the remove call and add it back to the source grid.

    However, for me, i guess since the method is "add" not "set", my spring service ends up being called twice on the server, once by me and once by the built-in code i quess? How can i avoid this?


    2. In the above example, its great since have access to the callback and can act on it, but in the "add" everything happens in "your code". How can i know if something goes wrong server-side when attempting to add the dragged records and reload the grids, present error message to the user etc. ?

    Cheers!

    Leave a comment:


  • Isomorphic
    replied
    Take a look at this sample. Note how updateCaches() is used to have the client-side pretend records have been removed when a server fetch would still return them.

    Leave a comment:


  • mathias
    started a topic Question about drag-drop in Listgrids

    Question about drag-drop in Listgrids

    Hello,

    i want to have two listgrids, doing COPY drag-drop from left to right.
    However, i want the source to not show those rows that have already been dragged to the left.

    Initially i have solved with a custom fetch operation with custom SQL, however, when i drag they do not disappear in the left one, not until i reload the page.

    If i do MOVE as drag action, a delete-request is issued and i don't want that, i only want the left grid to be visually filtered for the user's convenience.


    Is there a smart way to do this. Maybe a callback so that i can tell the left grid to reload itself? Or something even better?

    Pointers appreciated.
Working...
X