/// <summary>
 /// Generating the data grid columns.
 /// </summary>
 private void GenerateGridColumns()
 {
     DataGridExpander.ItemsSource = ItemSourceCollection;
     foreach (var item in ColumnsList.Where(x => x.Visibility.Equals(true)))
     {
         var column = new DataGridTextColumn
         {
             Header = item.Header,
             Binding = new Binding(item.ColumnName),
             Width = item.Width,
             Visibility = item.Visibility ? Visibility.Visible : Visibility.Collapsed
         };
     }
 }
        private void DataGrid_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            if (ColumnsList != null && ColumnsList.Count > 0)
            {
                totalWidth = ColumnsList.Sum(x => x.Width);
                currentWidth = ColumnsList.Where(i => i.Visibility.Equals(true)).Sum(x => x.Width);
            }
            if (nextInlineColumn != null && nextInlineColumn.Width > 0)
                if ((currentWidth + nextInlineColumn.Width) <= DataGridExpander.ActualWidth)
                {
                    ColumnsList[ColumnsList.LastIndexOf(nextInlineColumn)].Visibility = true;
                    FindCurrentAndNextColumn();
                }
                else if (currentWidth > ActualWidth)
                {
                    ColumnsList[ColumnsList.LastIndexOf(currentVisibleColumn)].Visibility = false;
                    FindCurrentAndNextColumn();
                }
            currentWidth = DataGridExpander.ActualWidth;
            GenerateGridColumns();

        }
Beispiel #3
0
        private void AddEditRow <M>(RenderTreeBuilder pBuilder, MGridAction pAction, bool pIsFilterRow, M pValue)
        {
            var visibleColumns = ColumnsList.Where(c => c.ShouldRenderColumn).ToArray();

            AddInlineTrHeight(pBuilder);

            pBuilder.OpenElement(577, "td");
            pBuilder.AddAttribute(578, "colspan", visibleColumns.Length);

            pBuilder.OpenElement(580, "table");
            pBuilder.OpenElement(581, "tbody");
            pBuilder.OpenElement(582, "tr");

            {
                pBuilder.OpenComponent <MForm <M> >(53);
                pBuilder.AddAttribute(587, nameof(MForm <M> .Model), pValue);
                pBuilder.AddAttribute(588, nameof(MForm <M> .IsInTableRow), true);
                pBuilder.AddAttribute(589, nameof(MForm <M> .Fields), (RenderFragment)((builder3) =>
                {
                    AddInlineFormFields(builder3, visibleColumns, pIsFilterRow);
                }));

                pBuilder.AddAttribute(594, nameof(MForm <M> .MFormGridContext), new MFormGridContext()
                {
                    Action = pAction
                });

                if (pIsFilterRow)
                {
                    pBuilder.AddAttribute(601, nameof(MForm <M> .EnableValidation), false);
                    pBuilder.AddAttribute(602, "data-is-filterrow", true);

                    pBuilder.AddAttribute(604, nameof(MForm <M> .OnValueChanged),
                                          EventCallback.Factory.Create <MFormValueChangedArgs <ExpandoObject> >(this, OnFilterValueChanged));
                }
                else
                {
                    //T == M here

                    pBuilder.AddAttribute(611, nameof(MForm <T> .OnValidSubmit), EventCallback.Factory.Create <MFormSubmitArgs>(this, async(a) =>
                    {
                        await OnFormSubmit(a);
                    }));

                    pBuilder.AddAttribute(616, nameof(MForm <T> .OnValueChanged), EventCallback.Factory.Create <MFormValueChangedArgs <T> >(this, OnEditValueChanged));

                    pBuilder.AddComponentReferenceCapture(618, (__value) =>
                    {
                        EditForm = (MForm <T>)__value;
                    });
                }

                pBuilder.CloseComponent();
            }

            pBuilder.CloseElement(); //tr
            pBuilder.CloseElement(); //tbody
            pBuilder.CloseElement(); //table

            pBuilder.CloseElement(); //td
        }