You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

listing.html 14 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>Listing &mdash; Documentation</title>
  7. <link rel="stylesheet" href="_static/sphinxdoc.css" type="text/css" />
  8. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  9. <script type="text/javascript">
  10. var DOCUMENTATION_OPTIONS = {
  11. URL_ROOT: '',
  12. VERSION: '',
  13. COLLAPSE_MODINDEX: false,
  14. FILE_SUFFIX: '.html',
  15. HAS_SOURCE: true
  16. };
  17. </script>
  18. <script type="text/javascript" src="_static/jquery.js"></script>
  19. <script type="text/javascript" src="_static/doctools.js"></script>
  20. <link rel="top" title="Documentation" href="index.html" />
  21. <link rel="up" title="4. Client Side API" href="client_side_widgets.html" />
  22. <link rel="next" title="Tree" href="tree.html" />
  23. <link rel="prev" title="Dialog Boxes" href="dialog.html" />
  24. </head>
  25. <body>
  26. <div style="background-color: #FFF; text-align: left; padding: 8px 0px"><img src="_static/banner300910.gif"></div>
  27. <div class="related">
  28. <h3>Navigation</h3>
  29. <ul>
  30. <li class="right" style="margin-right: 10px">
  31. <a href="genindex.html" title="General Index"
  32. accesskey="I">index</a></li>
  33. <li class="right" >
  34. <a href="modindex.html" title="Global Module Index"
  35. accesskey="M">modules</a> |</li>
  36. <li class="right" >
  37. <a href="tree.html" title="Tree"
  38. accesskey="N">next</a> |</li>
  39. <li class="right" >
  40. <a href="dialog.html" title="Dialog Boxes"
  41. accesskey="P">previous</a> |</li>
  42. <li><a href="index.html">Documentation</a> &raquo;</li>
  43. <li><a href="client_side_widgets.html" accesskey="U">4. Client Side API</a> &raquo;</li>
  44. </ul>
  45. </div>
  46. <div class="sphinxsidebar">
  47. <div class="sphinxsidebarwrapper">
  48. <h3><a href="index.html">Table Of Contents</a></h3>
  49. <ul>
  50. <li><a class="reference external" href="">Listing</a><ul>
  51. <li><a class="reference external" href="#listing-options">Listing Options</a></li>
  52. <li><a class="reference external" href="#listing-class">Listing Class</a></li>
  53. <li><a class="reference external" href="#creating-a-listing">Creating a Listing</a></li>
  54. <li><a class="reference external" href="#examples">Examples</a></li>
  55. </ul>
  56. </li>
  57. </ul>
  58. <h4>Previous topic</h4>
  59. <p class="topless"><a href="dialog.html"
  60. title="previous chapter">Dialog Boxes</a></p>
  61. <h4>Next topic</h4>
  62. <p class="topless"><a href="tree.html"
  63. title="next chapter">Tree</a></p>
  64. <h3>This Page</h3>
  65. <ul class="this-page-menu">
  66. <li><a href="_sources/listing.txt"
  67. rel="nofollow">Show Source</a></li>
  68. </ul>
  69. <div id="searchbox" style="display: none">
  70. <h3>Quick search</h3>
  71. <form class="search" action="search.html" method="get">
  72. <input type="text" name="q" size="18" />
  73. <input type="submit" value="Go" />
  74. <input type="hidden" name="check_keywords" value="yes" />
  75. <input type="hidden" name="area" value="default" />
  76. </form>
  77. <p class="searchtip" style="font-size: 90%">
  78. Enter search terms or a module, class or function name.
  79. </p>
  80. </div>
  81. <script type="text/javascript">$('#searchbox').show(0);</script>
  82. </div>
  83. </div>
  84. <div class="document">
  85. <div class="documentwrapper">
  86. <div class="bodywrapper">
  87. <div class="body">
  88. <div class="section" id="listing">
  89. <h1>Listing<a class="headerlink" href="#listing" title="Permalink to this headline">¶</a></h1>
  90. <p>The listing widget is used to show a list of values from the server. It is a widget that is completely
  91. scripted and gets the list from a plug-in SQL query. It also has many viewing and customizing options
  92. and manages paging of results.</p>
  93. <div class="section" id="listing-options">
  94. <h2>Listing Options<a class="headerlink" href="#listing-options" title="Permalink to this headline">¶</a></h2>
  95. <p>Features of a Listing widget can be controlled by setting the <cite>opts</cite> properties before calling the
  96. <cite>make</cite> function. The default Listing options are:</p>
  97. <div class="highlight-python"><pre>list_opts = {
  98. cell_style : {padding:'3px 2px'},
  99. // style for alternate row
  100. alt_cell_style : {backgroundColor:'#F2F2FF'},
  101. // style for header
  102. head_style : {height:'20px',overflow:'hidden',verticalAlign:'middle',textAlign:'center',fontWeight:'bold',padding:'1px',fontSize:'13px'}
  103. head_main_style : {padding:'0px'},
  104. // buttons
  105. hide_export : 0,
  106. hide_print : 0,
  107. hide_refresh : 0,
  108. hide_rec_label: 0,
  109. show_calc: 1,
  110. // clear tab on "refresh"
  111. show_empty_tab : 1,
  112. show_bottom_paging: 1,
  113. no_border: 0
  114. };</pre>
  115. </div>
  116. </div>
  117. <div class="section" id="listing-class">
  118. <h2>Listing Class<a class="headerlink" href="#listing-class" title="Permalink to this headline">¶</a></h2>
  119. <dl class="class">
  120. <dt id="Listing">
  121. <em class="property">class </em><tt class="descname">Listing</tt><big>(</big><em>head_text</em>, <em>no_index</em>, <em>no_loading</em><big>)</big><a class="headerlink" href="#Listing" title="Permalink to this definition">¶</a></dt>
  122. <dd><blockquote>
  123. <p><cite>head_text</cite> is the header of the widget, <cite>no_index</cite> means that the &#8220;Serial No&#8221; is not to be shown and
  124. <cite>no_loading</cite> means the &#8220;Loading...&#8221; spinner is to be hidden while the query is executed.</p>
  125. <dl class="attribute">
  126. <dt id="Listing.page_len">
  127. <tt class="descname">page_len</tt><a class="headerlink" href="#Listing.page_len" title="Permalink to this definition">¶</a></dt>
  128. <dd>Length of one page output. Default 20</dd></dl>
  129. <dl class="attribute">
  130. <dt id="Listing.paging_len">
  131. <tt class="descname">paging_len</tt><a class="headerlink" href="#Listing.paging_len" title="Permalink to this definition">¶</a></dt>
  132. <dd>Number of page pointers to be shown. Default 5</dd></dl>
  133. <dl class="attribute">
  134. <dt id="Listing.head_text">
  135. <tt class="descname">head_text</tt><a class="headerlink" href="#Listing.head_text" title="Permalink to this definition">¶</a></dt>
  136. <dd>Text to be shown at the heading. Default &#8220;Results&#8221;</dd></dl>
  137. <dl class="attribute">
  138. <dt id="Listing.keyword">
  139. <tt class="descname">keyword</tt><a class="headerlink" href="#Listing.keyword" title="Permalink to this definition">¶</a></dt>
  140. <dd>Keyword for each record. Default &#8220;records&#8221;</dd></dl>
  141. <dl class="attribute">
  142. <dt id="Listing.colnames">
  143. <tt class="descname">colnames</tt><a class="headerlink" href="#Listing.colnames" title="Permalink to this definition">¶</a></dt>
  144. <dd>List of column labels</dd></dl>
  145. <dl class="attribute">
  146. <dt id="Listing.coltypes">
  147. <tt class="descname">coltypes</tt><a class="headerlink" href="#Listing.coltypes" title="Permalink to this definition">¶</a></dt>
  148. <dd>List of column types</dd></dl>
  149. <dl class="attribute">
  150. <dt id="Listing.colwidths">
  151. <tt class="descname">colwidths</tt><a class="headerlink" href="#Listing.colwidths" title="Permalink to this definition">¶</a></dt>
  152. <dd><p>List of column widths.</p>
  153. <p><strong>The listing only shows as many columns as specified in the `colwidths`</strong></p>
  154. </dd></dl>
  155. <dl class="attribute">
  156. <dt id="Listing.coloptions">
  157. <tt class="descname">coloptions</tt><a class="headerlink" href="#Listing.coloptions" title="Permalink to this definition">¶</a></dt>
  158. <dd>List of column options. (Useful in case type is <cite>Link</cite>)</dd></dl>
  159. <dl class="attribute">
  160. <dt id="Listing.filters">
  161. <tt class="descname">filters</tt><a class="headerlink" href="#Listing.filters" title="Permalink to this definition">¶</a></dt>
  162. <dd>Dictionary of filter objects</dd></dl>
  163. <dl class="attribute">
  164. <dt id="Listing.is_std_query">
  165. <tt class="descname">is_std_query</tt><a class="headerlink" href="#Listing.is_std_query" title="Permalink to this definition">¶</a></dt>
  166. <dd>If this is true, it will add <cite>match</cite> permissions automatically. The query must be in <a class="reference external" href="glossary.html#term-standard-query"><em class="xref">Standard Query</em></a>
  167. format.</dd></dl>
  168. </blockquote>
  169. <dl class="method">
  170. <dt id="Listing.make">
  171. <tt class="descname">make</tt><big>(</big><em>parent</em><big>)</big><a class="headerlink" href="#Listing.make" title="Permalink to this definition">¶</a></dt>
  172. <dd>Create the UI in the given <cite>parent</cite> Element. All filters must be added before this method is called</dd></dl>
  173. <dl class="method">
  174. <dt id="Listing.add_filter">
  175. <tt class="descname">add_filter</tt><big>(</big><em>label</em>, <em>ftype</em>, <em>options</em>, <em>tname</em>, <em>fname</em>, <em>cond</em><big>)</big><a class="headerlink" href="#Listing.add_filter" title="Permalink to this definition">¶</a></dt>
  176. <dd>Add a filter input widget to the listing. See example</dd></dl>
  177. <dl class="method">
  178. <dt id="Listing.remove_filter">
  179. <tt class="descname">remove_filter</tt><big>(</big><em>label</em><big>)</big><a class="headerlink" href="#Listing.remove_filter" title="Permalink to this definition">¶</a></dt>
  180. <dd>Remove a filter</dd></dl>
  181. <dl class="method">
  182. <dt id="Listing.remove_all_filters">
  183. <tt class="descname">remove_all_filters</tt><big>(</big><big>)</big><a class="headerlink" href="#Listing.remove_all_filters" title="Permalink to this definition">¶</a></dt>
  184. <dd>Remove all filters</dd></dl>
  185. <dl class="method">
  186. <dt id="Listing.add_sort">
  187. <tt class="descname">add_sort</tt><big>(</big><em>column_index</em>, <em>fname</em><big>)</big><a class="headerlink" href="#Listing.add_sort" title="Permalink to this definition">¶</a></dt>
  188. <dd>Add a sorting feature to a particular column</dd></dl>
  189. <dl class="method">
  190. <dt id="Listing.set_default_sort">
  191. <tt class="descname">set_default_sort</tt><big>(</big><em>fname</em>, <em>sort_order</em><big>)</big><a class="headerlink" href="#Listing.set_default_sort" title="Permalink to this definition">¶</a></dt>
  192. <dd>Set the default sort property</dd></dl>
  193. <dl class="method">
  194. <dt id="Listing.run">
  195. <tt class="descname">run</tt><big>(</big><big>)</big><a class="headerlink" href="#Listing.run" title="Permalink to this definition">¶</a></dt>
  196. <dd>Execute the query</dd></dl>
  197. <dl class="method">
  198. <dt id="Listing.std_cell">
  199. <tt class="descname">std_cell</tt><big>(</big><em>d</em>, <em>ri</em>, <em>ci</em><big>)</big><a class="headerlink" href="#Listing.std_cell" title="Permalink to this definition">¶</a></dt>
  200. <dd>Render the standard output in the cell, <cite>d</cite> is the resultset, <cite>ri</cite> and <cite>ci</cite> are row index and
  201. column index</dd></dl>
  202. </dd></dl>
  203. </div>
  204. <div class="section" id="creating-a-listing">
  205. <h2>Creating a Listing<a class="headerlink" href="#creating-a-listing" title="Permalink to this headline">¶</a></h2>
  206. <p>To create a listing,</p>
  207. <ul class="simple">
  208. <li>Restrict the number of columns generated by specifying the <cite>colwidths</cite></li>
  209. <li>Optionally declare <cite>colnames</cite>, <cite>coltypes</cite> and <cite>coloptions</cite></li>
  210. <li>Declare the <cite>get_query</cite> method that will declare 2 queries
  211. * <cite>query</cite>
  212. * <cite>query_max</cite></li>
  213. <li>To customize the output, declare the <cite>show_cell(cell, ri, ci, d)</cite> method to render the cell content.</li>
  214. </ul>
  215. <p>See examples below</p>
  216. </div>
  217. <div class="section" id="examples">
  218. <h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h2>
  219. <p>Example of a customized listing:</p>
  220. <div class="highlight-python"><pre>// create a new listing
  221. var lst = new Listing();
  222. // define the columns etc
  223. lst.colwidths = ['5%','30%','15%','15%','20%','5%','10%'];
  224. lst.colnames = ['Sr.','Email','Status','','','',''];
  225. lst.coltypes = ['Data','Data','','','','',''];
  226. lst.coloptions = ['','','','','','',''];
  227. // define options
  228. var opts = {};
  229. opts.head_main_style = {};
  230. opts.cell_style = { padding:'3px 2px', borderRight : '0px', borderBottom : '1px solid #AAA'}
  231. opts.head_style = { padding:'3px 2px', borderBottom : '1px solid #AAA'}
  232. opts.alt_cell_style = {};
  233. opts.hide_print = 1;
  234. opts.no_border = 1;
  235. lst.opts = opts;
  236. // define the query
  237. lst.get_query = function(){
  238. // write your own query here
  239. this.query = repl("select name, enabled from ... where ... ");
  240. this.query_max = repl("select count(*) from ... where ...");
  241. }
  242. //show cell - customize output
  243. lst.show_cell = function(cell,ri,ci,d){
  244. if (ci==1){
  245. if (d[ri][ci]==1){
  246. var hl=$a(cell,'span','Data');
  247. hl.innerHTML = 'Enabled';
  248. $y(hl,{color:'GREEN'});
  249. }
  250. else if (d[ri][ci]==0){
  251. var hl=$a(cell,'span','Data');
  252. hl.innerHTML = 'Disabled';
  253. }
  254. } else{
  255. // show standard output
  256. lst.std_cell(d,ri,ci);
  257. }
  258. }
  259. // add filters
  260. lst.add_filter('Type', 'Select', ['','Old','New'].join(NEWLINE), 'Profile', 'user_type', '=');
  261. // generate
  262. lst.make(parent);</pre>
  263. </div>
  264. </div>
  265. </div>
  266. </div>
  267. </div>
  268. </div>
  269. <div class="clearer"></div>
  270. </div>
  271. <div class="related">
  272. <h3>Navigation</h3>
  273. <ul>
  274. <li class="right" style="margin-right: 10px">
  275. <a href="genindex.html" title="General Index"
  276. >index</a></li>
  277. <li class="right" >
  278. <a href="modindex.html" title="Global Module Index"
  279. >modules</a> |</li>
  280. <li class="right" >
  281. <a href="tree.html" title="Tree"
  282. >next</a> |</li>
  283. <li class="right" >
  284. <a href="dialog.html" title="Dialog Boxes"
  285. >previous</a> |</li>
  286. <li><a href="index.html">Documentation</a> &raquo;</li>
  287. <li><a href="client_side_widgets.html" >4. Client Side API</a> &raquo;</li>
  288. </ul>
  289. </div>
  290. <div class="footer">
  291. &copy; Copyright 2010, Rushabh Mehta.
  292. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.3.
  293. </div>
  294. </body>
  295. </html>