A javascript framework is required for every web application and jQuery is one of them. Today I delivered a presentation on jQuery in my company premises.
You can browse the demo application at following URL:
A javascript framework is required for every web application and jQuery is one of them. Today I delivered a presentation on jQuery in my company premises.
You can browse the demo application at following URL:
JSON has gain its popularity in web development and I was also exploring what is JSON and how is it useful in web development. I made a presentation and conducted a session about JSON at my company premises.
I was searching for a work around to allow view column to be sortable by clicking on column header but I was not able to find any reliable solution using View Panel. Now I found a way to provide this feature using Repeat Control or Data Table.
Please go through the following code.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
var loView:NotesView = null; var loEntryColl:NotesViewEntryCollection = null; var loTreeMap:java.util.TreeMap = new java.util.TreeMap(); var lsSortBy = viewScope.get("sortBy"); try { loView = database.getView("view"); if(null == lsSortBy || "" == lsSortBy) { lsSortBy = 0; } if(null != loView && loView.getEntryCount() > 0) { loEntryColl = loView.getAllEntries(); var loEntry:NotesViewEntry = loEntryColl.getFirstEntry(); var loTempEntry:NotesViewEntry = null; while(null != loEntry) { loDoc = loEntry.getDocument(); var lsKey = loEntry.getColumnValues().get(lsSortBy); while(loTreeMap.containsKey(lsKey)) { lsKey += "~"; } loTreeMap.put(lsKey, loEntry.getColumnValues()); loTempEntry = loEntryColl.getNextEntry(loEntry); loEntry.recycle(); loEntry = loTempEntry; } } } catch(e) { print("Error : " + e); } finally { if(null != loView) loView.recycle(); if(null != loEntryColl) loEntryColl.recycle(); } return loTreeMap.values(); |
In line 3 I am defining a TreeMap data structure. By definition TreeMap is sorted according to its natural ordering of its keys.
Since the data structure is always sorted so we can insert NotesViewEntry column values to the TreeMap and the corresponding column value (by which the view needs to be sorted) should be passed as key.
Look at line no 17 I am forming the key by which the view needs to be sorted. By default it is first column value.
At this point of time the only thing which creates problem is the duplicate values of the key. In TreeMap the value is overwritten if the key is already existing.
From line 18-21 I am appending additional character to make the key unique.
In line 37 I am returning value set from the TreeMap which is already sorted by key.
Rest of the code is quite easy to understand. I hope it may help in your application.