public MultiSearchViewModel2013() { //OrganizationServiceProxy.WithCredentials = true; DependentObservableOptions<string> throttledSearchTermObservable = new DependentObservableOptions<string>(); throttledSearchTermObservable.Model = this; throttledSearchTermObservable.GetValueFunction = new Func<string>(delegate { return this.SearchTerm.GetValue(); }); ThrottledSearchTerm = Knockout.DependentObservable<string>(throttledSearchTermObservable).Extend(new Dictionary("throttle", 400)); ThrottledSearchTerm.Subscribe(new Action<string>(delegate(string search) { // Search whilst typing using the throttle extension SearchCommand(); })); // Get Config Dictionary<string, string> dataConfig = PageEx.GetWebResourceData(); // Query the quick search entities QueryQuickSearchEntities(); Dictionary<string, Entity> views = GetViewQueries(); _parser = new QueryParser(); foreach (string typeName in _entityTypeNames) { Entity view = views[typeName]; string fetchXml = view.GetAttributeValueString("fetchxml"); string layoutXml = view.GetAttributeValueString("layoutxml"); // Parse the fetch and layout to get the attributes and columns FetchQuerySettings config = _parser.Parse(fetchXml, layoutXml); config.RecordCount = Knockout.Observable<string>(); config.DataView = new VirtualPagedEntityDataViewModel(25, typeof(Entity), true); config.RecordCount.SetValue(GetResultLabel(config)); Config.Push(config); // Wire up record count change config.DataView.OnPagingInfoChanged.Subscribe(OnPagingInfoChanged(config)); } _parser.QueryDisplayNames(); }
public MultiSearchViewModel2013() { //OrganizationServiceProxy.WithCredentials = true; DependentObservableOptions <string> throttledSearchTermObservable = new DependentObservableOptions <string>(); throttledSearchTermObservable.Model = this; throttledSearchTermObservable.GetValueFunction = new Func <string>(delegate { return(this.SearchTerm.GetValue()); }); ThrottledSearchTerm = Knockout.DependentObservable <string>(throttledSearchTermObservable).Extend(new Dictionary("throttle", 400)); ThrottledSearchTerm.Subscribe(new Action <string>(delegate(string search) { // Search whilst typing using the throttle extension SearchCommand(); })); // Get Config Dictionary <string, string> dataConfig = PageEx.GetWebResourceData(); // Query the quick search entities QueryQuickSearchEntities(); Dictionary <string, Entity> views = GetViewQueries(); _parser = new QueryParser(); foreach (string typeName in _entityTypeNames) { Entity view = views[typeName]; string fetchXml = view.GetAttributeValueString("fetchxml"); string layoutXml = view.GetAttributeValueString("layoutxml"); // Parse the fetch and layout to get the attributes and columns FetchQuerySettings config = _parser.Parse(fetchXml, layoutXml); config.RecordCount = Knockout.Observable <string>(); config.DataView = new VirtualPagedEntityDataViewModel(25, typeof(Entity), true); config.RecordCount.SetValue(GetResultLabel(config)); Config.Push(config); // Wire up record count change config.DataView.OnPagingInfoChanged.Subscribe(OnPagingInfoChanged(config)); } _parser.QueryDisplayNames(); }
public StartStopSessionViewModel(Guid activityToStartStop, Guid sessionToStartStop) { // Create start session dev1_session newSession = new dev1_session(); newSession.dev1_StartTime = DateTime.Now; StartSession = (Observable<SessionVM>)ValidatedObservableFactory.ValidatedObservable(new SessionVM(this, newSession)); // Load the Sessions dev1_session session = (dev1_session)OrganizationServiceProxy.Retrieve(dev1_session.EntityLogicalName, "{FD722AC2-B234-E211-A471-000C299FFE7D}", new string[] { "AllColumns" }); SessionVM sessionVM = new SessionVM(this, session); StopSession = (Observable<SessionVM>)ValidatedObservableFactory.ValidatedObservable(sessionVM); DependentObservableOptions<bool> isFormValidDependantProperty = new DependentObservableOptions<bool>(); isFormValidDependantProperty.Model = this; isFormValidDependantProperty.GetValueFunction = new Func<bool>(delegate { StartStopSessionViewModel vm = (StartStopSessionViewModel)isFormValidDependantProperty.Model; if (vm.StartNewSession.GetValue()) { return ValidationRules.AreValid( new object[] { ((StartStopSessionViewModel)isFormValidDependantProperty.Model).StopSession, ((StartStopSessionViewModel)isFormValidDependantProperty.Model).StartSession }); } else { return ValidationRules.AreValid( new object[] { ((StartStopSessionViewModel)isFormValidDependantProperty.Model).StopSession }); } }); CanSave = Knockout.DependentObservable<bool>(isFormValidDependantProperty); }
public DependentObservable <bool> CanAddNew() { if (_canAddNew == null) { DependentObservableOptions <bool> IsRegisterFormValidDependantProperty = new DependentObservableOptions <bool>(); IsRegisterFormValidDependantProperty.Model = this; IsRegisterFormValidDependantProperty.GetValueFunction = new Func <bool>(delegate { EntityStates state = SelectedContact.GetValue().EntityState.GetValue(); if (state != null) { return(state != EntityStates.Created); } else { return(true); } }); _canAddNew = Knockout.DependentObservable <bool>(IsRegisterFormValidDependantProperty); } return(_canAddNew); }
public DependentObservable<bool> CanAddNew() { if (_canAddNew==null) { DependentObservableOptions<bool> IsRegisterFormValidDependantProperty = new DependentObservableOptions<bool>(); IsRegisterFormValidDependantProperty.Model = this; IsRegisterFormValidDependantProperty.GetValueFunction = new Func<bool>(delegate { EntityStates state = SelectedContact.GetValue().EntityState.GetValue(); if (state != null) { return state != EntityStates.Created; } else return true; }); _canAddNew = Knockout.DependentObservable<bool>(IsRegisterFormValidDependantProperty); } return _canAddNew; }
public StartStopSessionViewModel(Guid activityToStartStop, Guid sessionToStartStop) { // Create start session dev1_session newSession = new dev1_session(); newSession.dev1_StartTime = DateTime.Now; StartSession = (Observable <SessionVM>)ValidatedObservableFactory.ValidatedObservable(new SessionVM(this, newSession)); // Load the Sessions dev1_session session = (dev1_session)OrganizationServiceProxy.Retrieve(dev1_session.EntityLogicalName, "{FD722AC2-B234-E211-A471-000C299FFE7D}", new string[] { "AllColumns" }); SessionVM sessionVM = new SessionVM(this, session); StopSession = (Observable <SessionVM>)ValidatedObservableFactory.ValidatedObservable(sessionVM); DependentObservableOptions <bool> isFormValidDependantProperty = new DependentObservableOptions <bool>(); isFormValidDependantProperty.Model = this; isFormValidDependantProperty.GetValueFunction = new Func <bool>(delegate { StartStopSessionViewModel vm = (StartStopSessionViewModel)isFormValidDependantProperty.Model; if (vm.StartNewSession.GetValue()) { return(ValidationRules.AreValid( new object[] { ((StartStopSessionViewModel)isFormValidDependantProperty.Model).StopSession, ((StartStopSessionViewModel)isFormValidDependantProperty.Model).StartSession })); } else { return(ValidationRules.AreValid( new object[] { ((StartStopSessionViewModel)isFormValidDependantProperty.Model).StopSession })); } }); CanSave = Knockout.DependentObservable <bool>(isFormValidDependantProperty); }