{"id":197,"date":"2007-05-17T15:55:07","date_gmt":"2007-05-17T23:55:07","guid":{"rendered":"http:\/\/spacefold.com\/colin\/morethanfour\/?p=197"},"modified":"2020-08-22T12:26:21","modified_gmt":"2020-08-22T20:26:21","slug":"an-alternative-to-checkboxes-for-logical-fields-in-grids","status":"publish","type":"post","link":"https:\/\/spacefold.com\/colin\/morethanfour\/2007\/05\/17\/an-alternative-to-checkboxes-for-logical-fields-in-grids\/","title":{"rendered":"An alternative to checkboxes for logical fields in Grids"},"content":{"rendered":"\n<p>I&#8217;ve never really been happy with how checkbox controls look when contained in Grid columns, displaying logical values. Lately I&#8217;ve been using the method described below.<\/p>\n\n\n\n<p>Given a table with a logical column such as:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">create cursor FILMLIST values ( VIEWED L, TITLE C(50) )<\/pre>\n\n\n\n<p>I use an expression for the grid column instead of referencing the table column name directly:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Alignment=2-(Middle Center)\nControlSource = iif(FILMLIST.VIEWED,\"\u00fc\",\" \")\nFontName=Wingdings\nFontSize=11\nReadOnly=TRUE<\/pre>\n\n\n\n<p>The default textbox control in the column will display the logical value as a tick mark (the WingDings character for \u00fc):<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/spacefold.com\/colin\/morethanfour\/wp-content\/uploads\/2007\/logical_column_display.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>This is all you need to do for a read-only column. For my users, I make the column editable by adding some code to the textbox&#8217;s .DblClick() event:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">replace FILMLIST.VIEWED with !nvl(FILMLIST.VIEWED,.F.)\nthis.Refresh()<\/pre>\n\n\n\n<p>This toggles the logical flag when the user double-clicks the mouse in the column &#8211; and handles possible NULL values as well.<\/p>\n\n\n\n<p>As an exercise for the student, try adding support for toggling the flag using the keyboard SPACE bar.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve never really been happy with how checkbox controls look when contained in Grid columns, displaying logical values. Lately I&#8217;ve been using the method described below. Given a table with a logical column such as: create cursor FILMLIST values ( VIEWED L, TITLE C(50) ) I use an expression for the grid column instead of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[],"class_list":["post-197","post","type-post","status-publish","format-standard","hentry","category-foxpro","post-preview"],"_links":{"self":[{"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/posts\/197","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/comments?post=197"}],"version-history":[{"count":0,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/posts\/197\/revisions"}],"wp:attachment":[{"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/media?parent=197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/categories?post=197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/tags?post=197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}