title: LightSwitch hide delete button until record is selected
body: <p>I'm using Visual Studio 2013 and LightSwitch. I figured out how to create a delete record button and it works great. The only problem I have is on my main page where all records are shown. </p>
  
  <p>When the page loads, The View &amp; Edit buttons only appear once I select a record. the Add and Delete are visible all the time. The problem is, while the delete function works, it only works when a record is selected. So, if the page loads and you click delete it errors out. I would like to hide the delete button until a record is clicked on. By default the Edit and View buttons that Lightswitch creates do this, however since you have to write your own Delete function I have not figured out how to do this.</p>
  
  <p>Here is an example of the C# i'm working with which works fine provided a record is selected..</p>
  
  <pre><code>myapp.BrowseGiftRegistries.DeleteRegistry_execute = function (screen) {
      screen.GiftRegistries.deleteSelected();
      return myapp.commitChanges().then(null, function fail(e) {
          myapp.cancelChanges();
          throw e;
      });
  };
  </code></pre>