Skip to content

Instantly share code, notes, and snippets.

@piscisaureus
Created August 8, 2011 16:10
Show Gist options
  • Save piscisaureus/1132056 to your computer and use it in GitHub Desktop.
Save piscisaureus/1132056 to your computer and use it in GitHub Desktop.
[17:25] == martin_js [915ec6de@gateway/web/freenode/ip.145.94.198.222] has joined #apf
[17:25] <martin_js> hey
[17:25] <martin_js> anyone here?
[17:26] <martin_js> I have a question about APF. Is it possible to have a datagrid cell contain another element, e.g. a checkbox or a combo?
[17:26] <mattpardee_> hello
[17:27] <mattpardee_> sure
[17:27] <mattpardee_> can you give me a little more detail about what you want to do?
[17:27] <martin_js> Heh
[17:27] <martin_js> I want to do something terribly complex :-)
[17:28] <mattpardee_> do you want a checkbox in each row?
[17:28] <martin_js> But for now I have a datagrid containing some data, could be like a name and a country
[17:29] <martin_js> I want the the name to be editable inline w/ a textbox, and for the country I want to use a dropdown (select) box
[17:30] <mattpardee_> ok
[17:30] <martin_js> It's trivial to make the grid display stuff -- <a:column value="[@name]" /> suffices
[17:30] <martin_js> but how do I tell to place an element instead of just a value
[17:30] <martin_js> * tell it
[17:31] <mattpardee_> perhaps <a:column value="[@name]"><a:checkbox checked="{[@name] == 'bob'}" /></a:column>
[17:32] <martin_js> eh
[17:32] <martin_js> sounds too easy :-)
[17:32] <mattpardee_> hehe
[17:32] <martin_js> trying it
[17:32] <mattpardee_> you're onto us!
[17:32] <mattpardee_> We prefer to call it "an adventure"
[17:32] <mattpardee_> and "mental abstraction exercises"
[17:32] <martin_js> :-)
[17:33] <martin_js> okay
[17:33] <martin_js> So now I have the terribly complex question
[17:33] <martin_js> (ps: I'm not asking you to do my job - I'll be *very* happy if you just gimme some hints)
[17:33] <mattpardee_> ok, np
[17:33] <mattpardee_> happy to help in any way I can
[17:35] <martin_js> Suppose I have this underlying model: employee - company. This is a many-to-many relationship. ...
[17:36] <martin_js> Now I want to have 1 view that shows all employees in a table, and have some control where I can select employers. I was thinking about a combo box that - when expanded - shows all possible companies with checkboxes in from
[17:36] <martin_js> *in front
[17:37] <martin_js> I *also* need the same kind of grid but for the opposite side of the relation, so list all the companies and put all possible employees in a dropdown
[17:37] <martin_js> Is it possible to create a binding for this sort of work?
[17:37] <mattpardee_> hmmm
[17:37] <martin_js> Or where would do I start hacking?
[17:39] <martin_js> In a relational model you would have an "association class" so your data model would look like:
[17:39] <martin_js> employee - {n..1} - job - {1..n} - company
[17:39] <mattpardee_> yeah
[17:39] <mattpardee_> I think you may be able to get away with this with just one model
[17:39] <martin_js> (actually I even need to associate some data with the job)
[17:39] <mattpardee_> oh ok
[17:40] <mattpardee_> then you'd obviously want 3 models
[17:40] <martin_js> Yeah
[17:40] <martin_js> That would be fine
[17:41] <mattpardee_> so 3 models, <a:model id="employees", id="employers", "jobs"
[17:41] <mattpardee_> and then you would just have to use selectors to get the right data for each iteration on each model
[17:42] <martin_js> hmm
[17:42] <mattpardee_> so for the employees model
[17:42] <mattpardee_> let's say you have a datagrid with expansion points for each company, to list employees for each company
[17:42] <martin_js> yeah
[17:42] <mattpardee_> this is more or less a tree, but I think to APF it doesn't matter. you can use a datagrid
[17:43] <mattpardee_> so you do <a:datagrid model="employers" …. > <a:each "employer">
[17:44] <mattpardee_> and then.. one sec
[17:44] <martin_js> okay :-)
[17:47] <martin_js> mattpardee_: I tried the <a:column><a:ckeckbox></a:column> think btw
[17:47] <mattpardee_> yeah?
[17:47] <martin_js> but it shows the control in the column header and not in the data cell
[17:47] <mattpardee_> ah\
[17:48] <mattpardee_> yeah admittedly I haven't worked with datagrids much
[17:50] <mattpardee_> would you be willing to paste the code into pastebin or something?
[17:50] <mattpardee_> your datagrid code
[17:53] <mattpardee_> I think ultimately you should use a tree
[17:53] <mattpardee_> I mean a tree inside of a datagrid
[17:53] <mattpardee_> I know there's a way to combine the two but I haven't worked on that before.
[17:54] <mattpardee_> are you going to be on for a while? I'm going to be wrapping up work in the next couple of hours and then can take a stab at this
[17:54] <martin_js> mattpardee_: https://gist.github.com/1132019
[17:55] <martin_js> I can stay on for a while if I can get webirc to not drop me
[17:55] <mattpardee_> if you do get dropped you can give me your twitter or github username and I can get back to you
[17:59] <martin_js> Ok so my coworker is going to talk to you I think
[18:01] <martin_js> He'll be online in a few minute (sorry for the complexity :-))
[18:01] <mattpardee_> no problem
[18:09] == piscisaureus [[email protected]] has joined #apf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment