Xpages Dojo Data Grid - Client Side Sorting - xpages

I want to be able to get the data and sort it in-memory. I am able to get JSON data using dojox.data.JsonRestStore. Now my question is how do I store it in memory and do in-memry sorting when I click on Dojo Datagrid headers. From what I have searched so far, it is not possible to sort the datagrid in-memory/client-side as it will request the sorted data from my Rest Service. As it is custom rest service, I am not able to sort the data on server side (or is it possible?).
Thanks in advance.
Arun

Outside of XPages, you should be able to set an attribute of the grid to do this -- clientSort: true
However, this doesn't seem to take effect within XPages. I tried the following, with no success:
Adding a clientSort attribute with a value of true to the grid control (via the Dojo tab). The attribute showed up in the right place in the page source, but had no effect. (Programmatically checking the property returned a value of undefined.
Setting [grid].clientSort = true on the onClientLoad event of the page. When checked programmatically, the property would show that it is now set to true, but it had no effect.
I even tried adding it to a grid created programmatically (without the Dojo Data Grid control) and it had no effect.
It appears that either XPages is wiping out the attribute or that it just doesn't work within XPages with a remote data source. (My first two attempts used a REST service. My third attempt used a remote XML data source.)
I still think it's worth attempting to see whether it works with a local data source (like a read-write item store), but I have not had a chance to try that yet.

Related

is it possible to use smart image in multi-composite field?

I tried using smart image in multi composite field. In that the images are getting persisted, the remaining fields in the multi composite fields are not getting persisted. when i edited the dialog for the first time the values are getting stored on the node. when i edit the dialog next time it is showing me empty fields for the fields other than smart image.
This won't work. SmartImage and SmartFile have some restrictions to them. And there are two different versions: SmartImage and SmartFile vs. Html5SmartImage and Html5SmartFile. Depending on your actual Version of CQ it is even only possible to have the smartimage as a separate tab without any other fields. On top of that the behaviour for the different browser and versions together with the configuration of your SmartImage have different outcomes in JCR. This is even true for AEM 5.6.1 and the Html5 versions of the the xtype.
I can't post the full solution (as the code is not mine) but give some pointers how you could achieve your requirement:
Write your own Widget that replaces the multifield xtype. The author called it genericmultifield and what it does is to open an additional configurable dialog for each item. In this dialog you have the full controll again. It stores each item as a separate node below your resource from where you open your main dialog.
Though you need good ExtJs knowledge to achieve this and considering AEM 6, with a complete new Touch UI I am not sure if it is wise to do so. I didn't have time to check out AEM6, but maybe they already have something like this in their new UI.

How to perform a simple search on Dojo DataGrid

For a project, I had to swictch from DataTable jquery plugin to Dojo.
Dojo is great and everything works fine !
But, I miss the dataTable's simple search form (http://datatables.net/).
I know that Dojo have the Filter plugin which could make that, but it's not simple, for the users, as the dataTable input field (at less two more click for a global search on a table :/).
I search all the web but i couldn't find an exemple with it :/
If someone has a clue ?
This depends on what kind of backend data store you are using to power your grid.
It's usually just a simple matter of calling grid.setQuery({name: "FooBar" , ignoreCase: true });
But lets say you are using an [AndOrReadStore][1], rather than a simple ItemFileReadStore, then you might specify the columsToQuery and the columnValue as well.
Remmber, you always query your grid not the store. The grid will pass the query on to the store.
So, to do what you want, just create a new input on your page. Capture key presses or onchange, and then query your grid accordingly. This will filter results that don't match.
The reason why you might use query, is because if your store is powered from the server, it will make sure to requery the backend.
However, if your grid is entirely loaded in memory, then you can do client side filtering by using filter().

ExtJs - Allowing user to modify position of form fields using drag and drop

We have been developing our application using ExtJs 4.0.7, and now we have a new feature request which will allow user to set the position of form fields, as per his choice, using drag and drop.
For example, if currently a form has fields arranged in rows, then the user can pick these fields and arrange them in columns, or he can move a field from first row to second etc..
The user is also allowed to save this layout and when he opens the screen again then he gets to see the fields arranged in the same manner he saved.
I have not been able to locate any example in ExtJS carrying such a functionality, so I was wondering if this is possible in ExtJS?
Also, as the user is allowed to save the layout, thus, will this involve storing of ExtJs code in database or dynamic generation of ExtJS code from server side.
Looking forward to guidance at this.
Thanks in advance.
The only example of such a beast I have seen is the Sencha Designer. It saved the complete JSON object that represents the form config ... I suppose it's doable, but good luck :)

How to add a property an ASP.Net user control or web page and have that property read by Microsoft coded-ui testing? (CUIT)

I am using Microsoft coded-ui testing (CUIT) in VS 2010 Ultimate to test an ASP.Net 4.0 site.
I have the source code to the ASP.Net site, so I can modify it as needed.
I've got record/playback working.
I can write simple assert statements in the test methods to check properties of the UITestControl descendents (HTML links, tables, etc.) and compare them to expected values.
I want to add properties to user controls (ASCX's) and pages in my site, to pass back useful values to the testing code.
For example, I have a user control that implements a menu which displays different sets of menu items depending on the role of the current user.
Rather than having the test script click at the various menu items to check whether or not they're present, I want to add a property to the user control. This property will return info to the caller, listing the menus and menu items present.
I've found info on the Net on how to do this in WinForms, but this code relies on accessability, which I believe is only useful for CUIT with WinForms. Likewise, I've found info on how to do it with WPF/SL.
The answer may be related to getting the UITestControl.NativeElement property, then calling a method that overrides GetProperty(), but I haven't been able to get this approach to work.
Can anyone provide a short code sample showing how to add a property to an ASCX or ASPX page, where that property can be written in C# code-behind, and read by Microsoft Coded UI Testing (CUIT) code?
Thanks!
Adam Leffert
http://www.leffert.com
I haven't found an answer to this question, but I have written some code to solve the underlying problem.
I realized that adding properties to user controls would keep the validation data together with the control under test, but only for the case where the section of UI was implemented as a user control.
There are at least two other cases I need to cover:
1) Third-party controls added to the page, for example ASPxGridView, ASPxTreeView, etc.
2) Items that are not visible in the UI, for example the user profile data for the current user.
When you're running CUIT validation code with a Web app, the data you have available is DOM data, i.e. a tree that represents the contents of the Document Object Model of the contents of the browser window. There is no Request object, .Net Page object, etc. This DOM data is accessible through the UIMap object.
I don't want to wrap the third-party controls in user controls, because doing so would disturb the application under test, causing me to re-write the application code that touches properties and events of the grid, tree view, etc. Too intrusive for testing code.
So I created a code interface (ITestable) that contains a dictionary of string values, and a list of ITestable children.
In the LoadComplete event handler of the master page, I create an ITestable for the master page and fill the list with child ITestable objects for the child page, which can themselves contain lists of children.
I serialize this object into JSON, then store it in a hidden field on the master page.
I added the hidden field to the UIMap.
The test validation code deserializes the ITestable, then looks through it for values that need validation.
The controls create their own ITestable objects, so they can easily fill the objects with values that may be needed for validation, rather than forcing the test code to manipulate the UI trying to read validation values.
For example, a tree view could return its contents without the testing code having to click on each node and try to read the value displayed there. Additional properties (visible, enabled, etc.) can be stored in the values dictionary for each ITestable object.
CUIT has some very powerful features. I would very much appreciate it if Microsoft would document some best practices for solving these non-trivial validation problems. I've read through the Microsoft documentation but haven't found much on this topic for Web apps.

Reverting CoreData data

I have an NSTableView which is populated via a CoreData-backed NSArrayController. Users are able to edit any field they choose within the NSTableView. When they select the rows that they have modified and press a button, the data is sent to a third-party webservice. Provided the webservice accepts the updated values, I want to commit those values to my persistent store. If, however, the webservice returns an error (or simply fails to return), I want the edited fields to revert to their original values.
To complicate matters, I have a number of other editable controls, backed by CoreData, which do not need to resort to this behaviour.
I believe the solution to this problem revolves around the creation of a secondary Managed Object context, which I would use only for values edited within that particular NSTableView. But I'm confused as to how the two MOC would interact with each other.
What's the best solution to this problem?
The easiest solution would be to implement Core Data's undo functionality. That way you make the changes to Core Data but if the server returns the error, you just rollback the changes. See the Core Data docs for details.

Resources