Beispiel #1
0
        public override MvcHtmlString GetTable(int id)
        {
            if (id == 1)
            {
                HeaderList = new List <string>();
                RowList    = Context.Companies.Take(20).ToList();
                FillPropNames(RowList.First());
                TagBuilder tableBuilder = new TagBuilder("table");
                tableBuilder.AddCssClass("table");
                tableBuilder.AddCssClass("table-hover");
                tableBuilder.GenerateId("myTable");
                #region thbuilder

                tableBuilder.InnerHtml += "<thead>";
                tableBuilder.InnerHtml += "<tr>";
                foreach (string th in HeaderList)
                {
                    tableBuilder.InnerHtml += "<th scope='col'>" + th + "</th>";
                }
                tableBuilder.InnerHtml += "<th scope='col'>Düzenle</th>";
                tableBuilder.InnerHtml += "<th scope='col'>Sil</th>";
                tableBuilder.InnerHtml += "</tr>";
                tableBuilder.InnerHtml += "</thead>";
                #endregion

                #region trbuilder

                tableBuilder.InnerHtml += "<tbody>";
                foreach (Company item in RowList)
                {
                    tableBuilder.InnerHtml += "<tr>";
                    foreach (string prop in HeaderList)
                    {
                        tableBuilder.InnerHtml += "<td name='" + prop + "'>" + item.GetType().GetProperty(prop)?.GetValue(item) + "</td>";
                    }
                    tableBuilder.InnerHtml += "<td id='c-" + item.GetType().GetProperty("id")?.GetValue(item) + "'><i onclick='Update(this)'; class='fa fa-edit' style='cursor:pointer'></i> </td>";
                    tableBuilder.InnerHtml += "<td id='c-" + item.GetType().GetProperty("id")?.GetValue(item) + "'><i onclick='Remove(this)'; class='fa fa-remove' style='color:red;cursor:pointer'></i> </td>";
                    tableBuilder.InnerHtml += "</tr>";
                }
                tableBuilder.InnerHtml += "</tbody>";

                #endregion

                return(MvcHtmlString.Create("<div class='row'><input type='text' class='form-control col-lg-8' id='TbSearch' placeholder='Arama için Yazınız'><input type='text' class='form-control col-lg-2' id='TbFilter' placeholder='Kriter Yazınız'><button id='BtnSearch' data-id='c' class='btn btn-info col-lg-2'>Ara</button></div>" + tableBuilder.ToString(TagRenderMode.Normal) + "<br><br><div class='text-center'><button id='BtnNext' data-id='c' class='btn btn-lg btn-success'> Devamını Gör</button></div><br><br><br>"));
            }
            return(NextTable.GetTable(id));
        }