예제 #1
0
        private void AddContentRow(RenderTreeBuilder pBuilder, T pEntry, MGridAction pAction)
        {
            Guid entryId = GetId(pEntry);

            bool rowEdit = EditRow.HasValue && EditRow.Value == entryId;

            pBuilder.AddMarkupContent(503, "\r\n");
            pBuilder.OpenElement(504, "tr");

            string cssClass = "m-grid-row";

            if (rowEdit)
            {
                cssClass += " m-grid-edit-row";
            }

            bool selected = Selected.HasValue && Selected == entryId;

            if (selected)
            {
                cssClass += " m-grid-highlight";
            }

            Formatter.AppendToTableRow(pBuilder, ref cssClass, pEntry, selected);

            pBuilder.AddAttribute(519, "class", cssClass);


            pBuilder.AddAttribute(522, "onclick", EventCallback.Factory.Create <MouseEventArgs>(this, (a) =>
            {
                OnRowClick(pEntry, a);
            }));

            pBuilder.AddEventStopPropagationAttribute(527, "onclick", true);


            pBuilder.AddAttribute(530, "ondblclick", EventCallback.Factory.Create <MouseEventArgs>(this, async(a) =>
            {
                await StartEditRow(pEntry, a);
            }));


            if (rowEdit)
            {
                EditValue = pEntry;
                AddEditRow(pBuilder, pAction, false, EditValue);
            }
            else
            {
                for (int i = 0; i < ColumnsList.Count; i++)
                {
                    IMGridColumn column = ColumnsList[i];

                    if (!column.ShouldRenderColumn)
                    {
                        continue;
                    }

                    pBuilder.OpenElement(550, "td");

                    Formatter.AppendToTableRowData(pBuilder, column, pEntry);

                    if (column is IMGridColumnGenerator <T> generator)
                    {
                        pBuilder.AddContent(556, generator.GenerateContent(pEntry));
                    }
                    else if (column is IMGridPropertyColumn pc)
                    {
                        var iprop = mPropertyInfoCache[pc];
                        pBuilder.AddContent(561, Formatter.FormatPropertyColumnValue(pc, iprop, pEntry));
                    }

                    pBuilder.CloseElement(); //td
                }
            }

            pBuilder.CloseElement(); //tr
        }