How to Bind Save Button's enable state to dataSource ? RRS feed

  • Question

  • User-1965265390 posted

    I am trying to figure out how to Bind Save button's enable Property to upshot's dataSource, so that whenever there isa change in dataSource

    button(entityState!='unmodified') is enabled  and disabled otherwise.

    Tuesday, May 29, 2012 12:45 PM

All replies

  • User-661350001 posted





    Tuesday, May 29, 2012 12:56 PM
  • User-661350001 posted


    create a Proeprty which will return boolean for example

    public bool isUnmodified


    return entityState=='unmodified';



    bind  isUnmodified  to Enabled property

    Tuesday, May 29, 2012 12:57 PM
  • User-1965265390 posted

    I should have been more clear on this.

    I am looking to subscribe to EntityState property of DataSource so that whenever there is change in Datasource, i can enable or disbale my button.

    Tuesday, May 29, 2012 1:24 PM
  • User1364817430 posted


    I think the way to do this is by defining a boolean propertie in your viewmodel of the entity. For example

    function ViewModel(data){
       self.hasChanges = data.isChanged;

    When you done this, you can simply bind this property to the enable attribute of the save button in your form

    <input type="submit" data-bind="enable: hasChanges()" value="save" />

    Hope this will help.

    Greetings Kristof

    Friday, July 27, 2012 1:08 AM