{"id":970,"date":"2017-05-31T00:39:05","date_gmt":"2017-05-31T06:39:05","guid":{"rendered":"http:\/\/www.idubbs.com\/blog\/?p=970"},"modified":"2017-05-31T00:39:05","modified_gmt":"2017-05-31T06:39:05","slug":"powerapps-no-items-to-show","status":"publish","type":"post","link":"https:\/\/www.idubbs.com\/blog\/2017\/powerapps-no-items-to-show\/","title":{"rendered":"PowerApps &ndash; No Items to Show"},"content":{"rendered":"<p>In a previous <a href=\"http:\/\/www.idubbs.com\/blog\/2015\/jslink-csr-to-override-there-are-no-items-to-show-in-this-view\/\" target=\"_blank\">JS Link \/ CSR post<\/a> we covered how to handle what is displayed in a web part when there are no items to show. SharePoint\u2019s default message is an ambiguous: <br \/>\u201cThere are no items to show in this view of the [listname] list\u201d<\/p>\n<p>Not an awesome user experience. Something a little more contextually relevant might be more helpful to users \u2013 either in a simple list view, or in a more complicated solution. <\/p>\n<p>A PowerApps Gallery control isn\u2019t any better &#8211; merely showing a blank record. The Data Table control, on the other hand, has a handy \u2018NoDataText\u2019 property that can be configured to display a message when the control is empty.&nbsp; <\/p>\n<p>So, what do we do when using Gallery controls \u2013 until a \u2018NoDataText\u2019 property is added and\/or the Data Table control allows for more configuration options? As is the answer with many things in PowerApps: We use a formula.<\/p>\n<p>Using an appropriate text field control within a Gallery control, we can replace the Text property with a formula like the following:<\/p>\n<p>If(CountRows([_List Name_])=0,&#8221;[_Put your message here_]&#8221;, ThisItem.Title)<\/p>\n<p>For a SharePoint list named: DefaultList you get the following: <\/p>\n<p>If(CountRows(DefaultList)=0,&#8221;Nothing to see here&#8221;, ThisItem.Title)<\/p>\n<p>The \u2018CountRows\u2019 function as you might guess returns the number of rows in the list.<\/p>\n<p>The \u2018If\u2019 function tells the control to set the displayed value of the control to \u201cNothing to see here\u201d if the condition (there are 0 rows) evaluates to \u2018true\u2019. If not, the value of the control is ThisItem.Title \u2013 the normal field value we would expect in the control. The text is only displayed when there are no items in the list.&nbsp; <\/p>\n<p>That\u2019s it. <img decoding=\"async\" class=\"wlEmoticon wlEmoticon-smile\" style=\"border-top-style: none; border-left-style: none; border-bottom-style: none; border-right-style: none\" alt=\"Smile\" src=\"http:\/\/www.idubbs.com\/blog\/wp-content\/uploads\/2017\/05\/wlEmoticon-smile-2.png\">&nbsp;<\/p>\n<h3>References<\/h3>\n<ul>\n<li><a href=\"https:\/\/powerapps.microsoft.com\/en-us\/tutorials\/working-with-formulas\/\" target=\"_blank\">Get started with formulas<\/a> \u2013 PowerApps<\/li>\n<li><a href=\"https:\/\/powerapps.microsoft.com\/en-us\/tutorials\/function-table-counts\/\" target=\"_blank\">CountRows reference<\/a> in PowerApps<\/li>\n<li><a href=\"https:\/\/powerapps.microsoft.com\/en-us\/tutorials\/function-if\/\" target=\"_blank\">If function<\/a> in PowerApps<\/li>\n<li><a href=\"https:\/\/powerapps.microsoft.com\/en-us\/tutorials\/control-data-table\/\" target=\"_blank\">Data table control in PowerApps<\/a><\/li>\n<li><a href=\"https:\/\/powerapps.microsoft.com\/en-us\/tutorials\/control-gallery\/\" target=\"_blank\">Gallery control in PowerApps<\/a><\/li>\n<li><a href=\"http:\/\/www.idubbs.com\/blog\/2015\/jslink-csr-to-override-there-are-no-items-to-show-in-this-view\/\" target=\"_blank\">JS Link \u2013 No items to show<\/a> blog post<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>In a previous JS Link \/ CSR post we covered how to handle what is displayed in a web part when there are no items to show. SharePoint\u2019s default message [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[33,4,10,96,11,21],"tags":[],"class_list":["post-970","post","type-post","status-publish","format-standard","hentry","category-client-side-rendering-csr","category-js-link","category-office365","category-powerapps","category-sharepoint","category-sharepoint-online"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pgWQ1-fE","jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.idubbs.com\/blog\/wp-json\/wp\/v2\/posts\/970","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.idubbs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.idubbs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.idubbs.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.idubbs.com\/blog\/wp-json\/wp\/v2\/comments?post=970"}],"version-history":[{"count":1,"href":"https:\/\/www.idubbs.com\/blog\/wp-json\/wp\/v2\/posts\/970\/revisions"}],"predecessor-version":[{"id":971,"href":"https:\/\/www.idubbs.com\/blog\/wp-json\/wp\/v2\/posts\/970\/revisions\/971"}],"wp:attachment":[{"href":"https:\/\/www.idubbs.com\/blog\/wp-json\/wp\/v2\/media?parent=970"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.idubbs.com\/blog\/wp-json\/wp\/v2\/categories?post=970"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.idubbs.com\/blog\/wp-json\/wp\/v2\/tags?post=970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}