Hi Tim and Chuck, thanks for your mails. I use Timothy solution. It is much better than mine.
Jens Am 08.05.2014 um 04:13 schrieb Timothy Worman <[email protected]>: > Jens: > > I’ve implement a SingleSelectionAjaxGrid that extends AjaxGrid. Actually, > it’s twice removed. :-) Anyway, I don’t think there’s any major changes in > the parent class. There’s a class variable for selectedObject and the > following override below ’toggleSelectionOfRow.’ The component has a api > binding for selectedObject. > > /** > * Toggles inclusion of row into selectedObjects() (i.e. selects and > * de-selects it). This component can only have one selected row. > */ > public WOActionResults toggleSelectionOfRow() { > //row was already selected > boolean _rowWasPreviouslySelected = (selectedObjects() != null && > selectedObjects().contains(row())); > selectedObjects().removeAllObjects(); > if (! _rowWasPreviouslySelected) { > setSelectedObject(row()); > selectedObjects().addObject(row()); > } else { > setSelectedObject(null); > } > return null; > } > > Also, in the wod, the tr for the row repetition has been updated as below. > This allows you to click anywhere in the tr to select. > > TableRowAndToggler: AjaxUpdateLink { > action = toggleSelectionOfRow; > updateContainerID = configurationData.updateContainerID; // VALID > id = toggleRowSelectionID; > elementName = "tr"; > class = rowClass; > style = rowStyle; > } > > Hopefully, this helps you out. > > Tim > UCLA GSE&IS > > > On May 7, 2014, at 9:15 AM, Chuck Hill <[email protected]> wrote: > >> Hi Jens, >> >> On 2014-05-07, 1:59 AM, "Dipl.-Ing. Jens Lünstedt" wrote: >> >> Hello, >> for my AjaxGrid I have two questions. (I'm not very familiar with JavaScript) >> How to define a single row selection? (At the moment I can select and >> deselect multiple rows). >> >> You mean that you want to prevent the user from selecting more than one row? >> It does not support that. You probably could in JavaScript, but this is >> probably the wrong UI for what you are doing. >> >> >> How can I react on the selection and deselection event in my Java Class? The >> setSelectedObjects method is not called. >> >> You can’t directly, AjaxGrid does that. >> >> I think what you want is to have a link or button in each row that does >> something when activated. Otherwise you are trying to bend AjaxGrid to do >> something it was not intended for. Neither you nor your users are likely to >> be happy. >> >> First you need a grid configuration like this: >> * { >> * title = "Actions"; >> * keyPath = ""; // Missing >> or empty keypath results in the current object itself being passed to >> component >> * component = "EmployeeActions"; // Name of >> WOComponent to be displayed in this column. Gets passed two bindings: value >> (Object), >> * // and grid >> (AjaxGrid) so that any other needed data can be accessed >> * cssClass = "alignCenter"; >> * } >> >> Then in the component some simple HTML like: >> <span style="float:middle"><WEBOBJECT NAME="Remove"/></span> >> >> Then use a regular link or an Ajax one, depending on what you want to happen: >> Remove: WOHyperlink { >> action = remove; >> string = "Remove"; >> } >> >> And implement the action method to do what you want. >> >> >> Chuck >> >> >> >> >> I can't find a description / example in the web. >> >> Thanks >> Jens >> >> UPDATE: I found a solution in checking the change of selectedObjects in >> public WODisplayGroup displayGroup() >> I don't know if that is a good solution but it works. >> _______________________________________________ >> Do not post admin requests to the list. They will be ignored. >> Webobjects-dev mailing list ([email protected]) >> Help/Unsubscribe/Update your Subscription: >> https://lists.apple.com/mailman/options/webobjects-dev/lists%40thetimmy.com >> >> This email sent to [email protected] >
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
