예제 #1
0
 /// <summary>
 /// Provides the base method for handling view events.
 /// </summary>
 /// <param name="sender">Event sender</param>
 /// <param name="e">View event</param>
 /// <param name="token">Cancellation token.</param>
 protected virtual async Task OnViewEventsAsync(object sender, ViewEvent e, CancellationToken token = default)
 {
     if (e.IsChild() && (e.IsOpened(false) || e.IsClosed(false)))
     {
         Model.OpenInlineViews = OpenInlineViews;
     }
     await InvokeAsync(() => StateHasChanged());
 }
예제 #2
0
        /// <summary>
        /// Updates selection in the specified list object for a details open/close event
        /// using the provided key property on the details view object.
        /// </summary>
        /// <param name="list">Data list object to update.</param>
        /// <param name="keyChildProp">The key property on the child details view.</param>
        /// <param name="e">Open/close event of the child details view.</param>
        /// <returns></returns>
        protected virtual bool UpdateListSelection(DataListObject list, DataProperty keyChildProp, ViewEvent e)
        {
            // Find key property in the list with the same name, as the key property in the child details object.
            var keyListProp = list?.Properties?.Where(p => p.IsKey && p.Name == keyChildProp?.Name)?.FirstOrDefault();

            if (keyListProp != null)
            {
                if (e.IsOpened())
                {
                    list.SelectedRows = list.GetData().Where(r => Equals(keyListProp.GetValue(ValueFormat.Internal, r),
                                                                         keyChildProp.InternalValue)).ToList();
                }
                else if (e.IsClosed())
                {
                    list.ClearSelectedRows();
                }
                return(true);
            }
            return(false);
        }