6
$\begingroup$

I am reading data from a SQL Database and want to manually sellect multiple rows. ListPicker works very nicely, the only added complication is that I need to not only select the records, but also visually explore the relationship between rows and then occationally add to my selection based on relationship.

As a concrete example, say I have this:

dataImport = {{"Unique Number", "Customer", "Re-order", "Comment" , "Amount"},
              {"1001", "cust a", "No", "Comment 1" , "1234"}, 
              {"1002", "cust a", "Yes", "Comment 2" , "200"}, 
              {"1003", "cust b", "No", "Comment 3" , "290"}, 
              {"1004", "cust c", "No", "Comment 4" , "1000"}, 
              {"1005", "cust b", "Yes", "Comment 5" , "876"}};

I then can easily get: (lets ignore the formatting for now ...)

              ListPicker[Dynamic@selectList, dataImport]

I need some functionality where I can select multiple rows - as is the default ListPicker functionality. But I also want to be able to say right-click (or click on an embedded tick box for a record if that customer has a re-order, then those re-orders will be shown in a popup window - with the possibility of then selecting those records so that they are also added to selectList.

I have tried adding a column containing Checkbox[ ] - problem is

  • ListPicker only allows for the selection of complete rows and does not register selection of anything within a row.
  • Each Checkbox[] would need an unique variable name, and the number of unique names will be determined by the SQL query, and I may do multiple queries to trim the list down by customer or amount.

Any advice or pointers? Since there can be say 1000 rows in my selection (which I will then further refine to about say 100) the solution needs to be responsive.

$\endgroup$
  • $\begingroup$ Can you Map ListPicker to columns within rows? $\endgroup$ – alancalvitti Dec 17 '14 at 21:15
  • $\begingroup$ Feel free to ask if you have any questions. $\endgroup$ – Kuba Dec 18 '14 at 11:35
3
$\begingroup$

Not sure about general concept but maybe you can use this minimal example and extend/adjust to your needs:

Grid[{{
   ListPicker[
    Dynamic[selectList, (selectList = #;
                         re = Select[selectList, #[[3]] === "Yes" &]) &],
    dataImport]
   ,
   Dynamic @ If[TrueQ[re === {}],
                "",
                {"Include previous orders of " <> #2, 
                 Button["+", selectList = Union@Join[selectList, 
                               Select[dataImport, Function[s, s[[2]] === #2]]]]
                } & @@@ re // Grid
     ]
   }}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.