@@ -134,6 +134,12 @@ public class DocumentsListGrid extends RefreshableListGrid implements DocumentsG
134134 */
135135 protected List <String > extendedAttributes = new ArrayList <>();
136136
137+ /*
138+ * A cache of summaries, it seems that a bug in SmartGWT deletes the content
139+ * of the summary field when the user expands the row the second time
140+ */
141+ protected Map <Long , String > summaries = new HashMap <>();
142+
137143 private DocumentsListGrid (GUIFolder folder , List <String > extendedAttributes ) {
138144 this .folder = folder ;
139145 if (extendedAttributes != null )
@@ -219,7 +225,7 @@ public DocumentsListGrid(List<String> extendedAttributes) {
219225 * Prepares the map that contains all the possible fields we can use
220226 */
221227 protected void prepareFieldsMap () {
222- ListGridField id =new IdListGridField ();
228+ ListGridField id = new IdListGridField ();
223229 fieldsMap .put (id .getName (), id );
224230
225231 ListGridField size = new FileSizeListGridField ("size" , I18N .getAttributeLabel ("size" ));
@@ -763,21 +769,26 @@ public void setCanExpandRows() {
763769 setCanExpandRecords (true );
764770 setExpansionMode (ExpansionMode .DETAIL_FIELD );
765771 setDetailField (SUMMARY );
766-
767772 }
768773
769774 @ Override
770775 protected Canvas getExpansionComponent (final ListGridRecord rec ) {
771- return new HTMLFlow ("<div class='details'>"
772- + (rec .getAttributeAsString (SUMMARY ) != null ? rec .getAttributeAsString (SUMMARY ) : "" ) + "</div>" );
776+ return new HTMLFlow ("<span class='details'>" + summaries .get (rec .getAttributeAsLong ("id" )) != null
777+ ? summaries .get (rec .getAttributeAsLong ("id" ))
778+ : "" + "</span>" );
773779 }
774780
775781 @ Override
776782 public void setDocuments (List <GUIDocument > documents ) {
777783 List <ListGridRecord > records = new ArrayList <>();
784+ summaries .clear ();
778785
779- for (GUIDocument document : documents )
780- records .add (DocumentGridUtil .fromDocument (document ));
786+ for (GUIDocument document : documents ) {
787+ ListGridRecord rec = DocumentGridUtil .fromDocument (document );
788+ records .add (rec );
789+ if (document .getSummary () != null && !document .getSummary ().isBlank ())
790+ summaries .put (rec .getAttributeAsLong ("id" ), document .getSummary ());
791+ }
781792
782793 setRecords (records .toArray (new ListGridRecord [0 ]));
783794 }
0 commit comments