How to perform a simple search on Dojo DataGrid - search

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().

Related

Xpages using 'flags' for different doc. structure on same xpage

My scenario:
The xpage ( document content ) has a complex structure. I have a 1st button which opens this xpage, having in the postNewDocument:
Contr.replaceItemValue("txt_codformularmain","01") // I use this field as a flag.
Now, there is another button which compose the same xpage ... but in this case, I do want the xpage to be different, in other words to have some additional / showed fields.
I could add another code at the postNewDocument, like this:
Contr.replaceItemValue("txt_codformularmain2","01")
Later on, in some views I will filter the listed documents by this 2 fields: some views will be listing the documents where txt_codformularmain=01, other views for txt_codformularmain2=01, and so on.
All the fields are on the same form element. ( I could create easily 2 different xpages, with 2 document contents, but in the form Properties at onOpen and onWebAccess settings, I can add only one xpage )
But, I think it isn't the best approach for this. Because in both cases, postNewDocument takes place, and both fields are having the value 01.
In classic lotus notes programming, I had used only one field ( flag ) and for every different button, inside the button's code I just changed the field value: 01, 02, and so on, before the newDocument had been composed.
Should I use another/ a better approach?
I might go for creating a new form with the fields needed there, and creating a new XPage binded to that form...
dominoDocument.isNewNote() will tell you if it's a new document or not. You can compute visibility based on that.
If it's based on a field value, then again set the visibility based on what the value should be for the panel to be visible - instead of getComponent().getValue() use dominoDocument.getItemValueString() assuming it's a Text field for best practice. In the onblur event of the control that's bound to the field you're checking against, trigger a partial refresh. You will need to amend the default partial refresh settings if there is validation on the page.
Once you're comfortable with that technique, start thinking about using a dataContext to hold whether or not an area should be visible, and referencing that dataContext variable in the rendered property. The benefits of this are not only performance, but youo can give a better variable name to the dataContext to make it clearer when supporting the application what the logic is behind it being visible. For someone supporting the Notes Client app, for example, it's unclear without hunting what state "01" or "02" means. Descriptors like "newDoc", "published", etc have an advantage there.
Another method of optimisation would be to use a Dynamic Content control.
But it sounds like your XPage is going to be complex enough without adding more complexity at this stage.

Create domino view dynamically in XPages

I want to know if I can click a button in my XPage and dynamically create a Domino View and then show it in a panel control on the same page. The reason I want to do this is because I have a categorized view and I don't want to lose category data by using full text search. So I am thinking of creating a new view dynamically and pass my search parameters, like end date or start date, into the view selection formula.
Is it possible? Any other alternative solution is also welcome.
yes you can, but you don't want to. A Domino view takes space in the database and quite some time for its first use. So you end up with a lot of views taking space and the need to adjust database space after removal. Your response times will suck big time.
Categories as shown in Notes views are no web interaction pattern, so you might want to solve a problem that actually shouldn't exist.
The preferred method for Domino application is navigation / drill down over search. But you could do a FTSearch where you add your category to the search parameters and render your results in a repeat control instead of a view control. There you have more control over the look and feel.
Whether or not it's the best solution, the answer to the immediate question about creating a view on the fly is yes: the Database class has a couple "createView" methods to allow you to create a new view, either entirely from scratch or based on a named other view. From there, you can use the "setSelectionFormula" and "createColumn" methods in the created View to build what you want. You can't do EVERYTHING with those methods, but it may be enough.
One problem you'd likely run into is ACL access: you'll need Designer rights to the database, which a normal user most likely wouldn't have. If you use the sessionAsSigner object to fetch a signer version of the DB (say, "var signerDB = sessionAsSigner.getDatabase(database.getServer(), database.getFilePath())"), you can work from there. Off the top of my head, I don't remember if you will also have to up the "Maximum Internet access" setting on the last tab of the ACL to Designer as well, but you may.
I am assuming that you are referring to the problem that exists when you choose the documents based on the category. This is something that I find highly annoying and I wish that it was possible to turn this on and off. It makes sense for embedded views, but not for much else.
What I did to solve this was to include the category value in the next column. In this way that text could still be seen, even if it was a flat view.
Alternatively, you could also look into using a repeater control and create your own way of presenting the information. This would be used instead of a (Dynamic)ViewPanel control. You could then present the information any way you wanted as long as it is returned in the viewrow set.
Happy Programming!

Xpages Dojo Data Grid - Client Side Sorting

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.

Dojo DataGrid (8.5.3 UP1) Returning Blank Rows - based on Readers field

Trying out a Dojo DataGrid control on an alternate XPage (so as not to impact production) for an existing View, which utilizes Readers fields in the documents. I've got the REST service implemented (xe:viewItemFileService) and connected to the Dojo DataGrid just fine (from 8.5.3 UP1 controls).
I have two scenarios of user visibility (via Roles in the Readers field, assigned by NAB Group definition):
All documents visible (user A). User A can see all documents, everything works perfectly fine for this one.
User B can see some documents. ViewPanel control works fine, but once it's in the Dojo DataGrid, it only has values for the documents User B should see, the remaining X (difference between correctly visible and total document count) rows are populated with "..." (non-values).
Inspecting the REST service's output via the pathInfo yields only the correct documents for User B; which I take as a good sign and makes me think the Dojo DataGrid is what's misbehaving.
Actual Question:
How can I suppress the generation of the unnecessary rows?
I've tried to implement Marky Roden's approach, but got lost on the manipulation of how I can control what the DataGrid is looking at to generate row count (he's talking programmatic store definitions when I'm using the xe:djxDataGrid control). The attribute of rowsPerPage doesn't seem right, and I can't find one for the xe:restService that would make sense to me for what I'm looking for.
Anyone know how to do this? Would love to get this work. Been loving the series by Brad Balassaitis and what XPages can do for us.
Setup:
Domino Server 8.5.3 UP1
NSF signed as Server ID
The grid gets the hint for the number of rows from ?readViewEntriews which tells the actual number, not just the number of documents user B can see. Anyway just romping through reader protected views without designing for access speed has huge performance ramifications. If you can categorize the view by the combined reader/author fields and limit to that category both performance and empty rows will go away.
If you have multiple possible hits (username, role, group membership), you might want to use a rest service that returns data using some SSJS using a viewNavigator

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 :)

Resources