my little slice of the dark side of the dojo equationIt's a weird, upside down world. Honestly I need to give up trying to understand what is going on.
But I have to say, learning the new Domino stuff has put some umph in my day. I'm having more fun writing code than I have in a long time. Some of the things dojo brings to the party are just really incredible.
With dojo there is a significant learning curve, but once I get past it for "this dijit" or "that dojo feature", my development time speeds up, with the result being a more professional looking and more feature rich application that requires less testing across browsers, and all the while I'm still able to get all the benefits I always have from Domino apps - the flexible data store, the security, easily implemented hide-when logic, computed text, and on and on.
This makes me happy. :-)
There is however a dark side of the equation. With dojo, we are dealing with an open source project. There is quite a bit of documentation, but it's pretty thin. I find a lot of documentation on what they call the "api", but often the methods or properties are only listed, with no explanation, anywhere. dojox is even worse. There is an O'Reilly book covering dojo, but it doesn't cover dojox, because the dojox libs are "more experimental" and "too much material to cover" etc.
The examples I've found covering dojox grids only go so far in explaining what is there. There are so many layers of code to understand - like the dojo.data layer for example. dojo is incredibly powerful, and the dijit and dojx code use all the other stuff that is there in dojo core and base, so to get your head around dojox grids for instance, there are a lot of other things to understand, and you almost have to grok it completely to get the most out of it.
I'm working on that. ;-)
To make matters more complicated, when I dig into the dojo source code I find a lot of methods that aren't documented at all. I find methods that look incredibly useful. But if they are not documented as official api calls, I worry that if I use them, they could disappear in a future version of dojo, and then in a future server upgrade I could lose functionality. Applications could break. And yet it seems there isn't a way to get things done sometimes without using an undocumented call.
And so all of this brings me at last to my dojox conundrum. If you aren't a developer, and you've already managed to read this far, you can stop reading now, the rest is going to be even more boring!
I've got a few grids working in an application. But I've got some thorny problems I haven't researched my way out of yet, and I'm running out of time, so I'm hoping there might be some simple answers to what seem like simple questions.
OK, here goes!
I have a grid, established inside a dijit tab container. Actually a couple of them, and they are pretty neat!
The requirements for the grid are pretty simple:
1. Just one column.
2. The column has names in it.
3. I add names to the column, and remove them, with buttons (Add/Remove) that are below the grid. Names are added programmatically via a custom name picker - added to the ItemFileWriteStore.
4. When I add a name to the column, that name should be highlighted.
Everything good so far, all of that works OK, except adding back names that have been previously removed (working on that - something to do with the ItemFileWriteStore, I think).
But the things I can't seem to figure out are:
1. I can't get it to sort, from a programmatic call. In other words, if I call mygrid.sort() nothing happens. I can't seem to turn on the sorting programmatically. It only happens when the user clicks the header. I've been digging around in the source code to find out what is being called, but I haven't found it yet. Where do I find that listener? What is it calling?
2. If I click the header, then sorting turns on. After that, things get weird. Here's why:
If I add a new name to the column, it sorts automatically. Cool. This is actually what I want to happen. But, the code that I run to select (aka highlight in the grid) the correct name (the one that was just added) runs, and then some more code runs that is dojox code (this is dojox code that runs after, or is a part of, the sort routine that is now called by a listener when the FileItemWriteStore gets updated). So what happens is, the dojox code selects a row. It seems to select the row number that it was on before. Not the name, but the index. The result is, now two rows are selected. And the row I selected has moved around, and so now neither of the rows are the one I want.
My code, the code that selects/highlights the row that contains the name that was just added to the column, works fine, as long as sorting is not running yet.
So what I'm looking for is:
1. How do you get the grid to sort automatically (programmatically) without someone clicking on the header? I've tried setting all sorts of things in various combinations besides just mygrid.sort(), like setting sortInfo, etc. Nothing works. I'm using (and not using in another example) a ComparatorMap that works great once sorting is in effect, on the ItemFileWriteStore object. I say that to say, I've gotten somewhat deep with the intricacies of sorting, and yet I can't do something as simple as start up sorting programmatically.
2. Is there a way to turn off the grid column header's listener? So that when someone clicks it, it doesn't do anything? I don't want it to sort in descending order, ever, for instance. Setting mygrid.clientSort = false makes no difference at all.
3. Where do I put code that can run AFTER the sort routine does its thing? I want to programmatically select the correct name, and then scroll to it, if need be, once the sorting is done. I don't want to resort to setTimeout, I know there must be a clean way to do it - some piece of code I need to add a dojo.connect call to or something like that?
Well there you have it. Hopefully someone out there has been down this path. This seems like pretty simple stuff. I've been scouring the documentation for weeks, I've been googling and reading fora, etc, and now I'm digging into the dojox source code. I'll figure it out eventually, I mean what choice do I have? But in the meantime with any luck someone knows the answers to these questions already... I'm facing the possibility of having to roll my own grid due to time considerations (and, let's call it management fatigue), it's just one column with a limited set of requirements after all, but I really don't want to!
discussion thread| 1 |
Jon:
Have you reached out to Viktor Krantz? He is one of the Dojo gurus in the Lotus community and would be able to point you in the right direction.
We're going to be on 8.5.2 in a month or so and it will be my turn to go through what you are right now :-)
FUN !
Dan
| 2 |
I did actually, but he's a busy guy, between SNAPPS and, as I understand, P90X (not to mention a family), haven't heard back from him.
dojo IS fun! But when it isn't, man, it's a bag of cats.
| 3 |
Hey there, got your note. I'm rusty, but happy to help. Don't have any immediate answers, but could probably work through it with you. Now you've got my email, shoot me a note with a time that works for you to sit down for an hour or so.
| 4 |
Have you seen the openntf IBM extension library for xpages, i know they have a dojo grid and and some examples
| 5 |
Lance - thanks!
Mark, do you mean the new one they just put out that requires 8.5.2?
I'll look at it. We are still on 8.5.1 but there might be something in there that will give me a clue... thanks!
| 6 |
Got it figured out, just a couple of tweaks here and there.
| 7 |
that's because u r the man!! will be implementing on monday... can't thank you enough sir!
:-)
| 8 |
Answer to q #1 - get it to sort, from a programmatic call
g.setSortIndex(0,true);
g.render();
