Skip to content

Commit

Permalink
CRUD form input width configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavnavar committed Jul 13, 2020
1 parent 881bef6 commit 80ecfdd
Show file tree
Hide file tree
Showing 20 changed files with 67 additions and 31 deletions.
8 changes: 8 additions & 0 deletions GridBlazor/Columns/GridColumnBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public abstract class GridColumnBase<T> : GridStyledColumn, IGridColumn<T>, IExp

public string Width { get; set; }

public int CrudWidth { get; set; } = 5;

public bool SortEnabled { get; protected set; }

public string Title { get; set; }
Expand Down Expand Up @@ -119,6 +121,12 @@ IGridColumn<T> IColumn<T>.SetWidth(string width)
return this;
}

IGridColumn<T> IColumn<T>.SetCrudWidth(int width)
{
CrudWidth = width;
return this;
}

IGridColumn<T> IColumn<T>.SetWidth(int width)
{
Width = width.ToString(CultureInfo.InvariantCulture) + "px";
Expand Down
2 changes: 1 addition & 1 deletion GridBlazor/GridBlazor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<LangVersion>8.0</LangVersion>
<GenerateEmbeddedFilesManifest>True</GenerateEmbeddedFilesManifest>
<EnableDefaultEmbeddedResourceItems>False</EnableDefaultEmbeddedResourceItems>
<Version>1.7.0</Version>
<Version>1.7.1</Version>
<Title>GridBlazor</Title>
<Description>Grid components for Blazor</Description>
<Summary>Grid components for Blazor</Summary>
Expand Down
2 changes: 1 addition & 1 deletion GridBlazor/Pages/GridCreateComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
{
<label for="@column.FieldName" class="col-form-label col-md-2">@column.Title</label>
}
<div class="@(type == typeof(bool)?"col-md-1":"col-md-5")">
<div class="@(type == typeof(bool) ? "col-md-1" : "col-md-" + column.CrudWidth.ToString())">
@if (((IGridColumn<T>)column).IsSelectField.IsSelectKey)
{
var selectedValue = column.GetFormatedValue(value);
Expand Down
2 changes: 1 addition & 1 deletion GridBlazor/Pages/GridDeleteComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
{
<label for="@column.FieldName" class="col-form-label col-md-2">@column.Title</label>
}
<div class="@(type == typeof(bool)?"col-md-1":"col-md-5")">
<div class="@(type == typeof(bool) ? "col-md-1" : "col-md-" + column.CrudWidth.ToString())">
@if (((IGridColumn<T>)column).IsSelectField.IsSelectKey)
{
string text = ((IGridColumn<T>)column).GetFormatedValue(((IGridColumn<T>)column).IsSelectField.Expression, Item);
Expand Down
2 changes: 1 addition & 1 deletion GridBlazor/Pages/GridReadComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
{
<label for="@column.FieldName" class="col-form-label col-md-2">@column.Title</label>
}
<div class="@(type == typeof(bool)?"col-md-1":"col-md-5")">
<div class="@(type == typeof(bool) ? "col-md-1" : "col-md-" + column.CrudWidth.ToString())">
@if (((IGridColumn<T>)column).IsSelectField.IsSelectKey)
{
string text = ((IGridColumn<T>)column).GetFormatedValue(((IGridColumn<T>)column).IsSelectField.Expression, Item);
Expand Down
2 changes: 1 addition & 1 deletion GridBlazor/Pages/GridUpdateComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
{
<label for="@column.FieldName" class="col-form-label col-md-2">@column.Title</label>
}
<div class="@(type == typeof(bool) ? "col-md-1" : "col-md-5")">
<div class="@(type == typeof(bool) ? "col-md-1" : "col-md-" + column.CrudWidth.ToString())">
@if (column.IsPrimaryKey)
{
<input id="@column.FieldName" name="@column.FieldName" class="form-control" readonly="readonly" value="@column.GetFormatedValue(value)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ public static Action<IGridColumnCollection<Order>, IList<Func<object, Task>>, ob
.SetInputType(InputType.Week)
.SetFilterWidgetType("Week")
.RenderValueAs(o => DateTimeUtils.GetWeekDateTimeString(o.OrderDate))
.SetWidth(120);
.SetWidth(120)
.SetCrudWidth(3);

/* Adding "CompanyName" column: */
c.Add(o => o.Customer.CompanyName).Titled(SharedResource.CompanyName)
Expand All @@ -235,10 +236,10 @@ public static Action<IGridColumnCollection<Order>, IList<Func<object, Task>>, ob
.RenderValueAs(o => o.Customer.IsVip ? Strings.BoolTrueLabel : Strings.BoolFalseLabel).SetCrudHidden(true);

/* Adding hidden "RequiredDate" column: */
c.Add(o => o.RequiredDate, true).Format("{0:yyyy-MM-dd}");
c.Add(o => o.RequiredDate, true).Format("{0:yyyy-MM-dd}").SetCrudWidth(3);

/* Adding hidden "ShippedDate" column: */
c.Add(o => o.ShippedDate, true).Format("{0:yyyy-MM-dd}");
c.Add(o => o.ShippedDate, true).Format("{0:yyyy-MM-dd}").SetCrudWidth(3);

/* Adding hidden "ShipName" column: */
c.Add(o => o.ShipName, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<RazorLangVersion>3.0</RazorLangVersion>
<Version>1.7.0</Version>
<Version>1.7.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion GridBlazorOData.Client/GridBlazorOData.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<RazorLangVersion>3.0</RazorLangVersion>
<Version>1.7.0</Version>
<Version>1.7.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions GridBlazorOData.Client/Pages/Crud.razor
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ else
c.Add(o => o.CustomerID, true).SetSelectField(true, o => o.Customer.CustomerID + " - " + o.Customer.CompanyName, () => GetAllCustomers(baseUri));
c.Add(o => o.EmployeeID, true).SetSelectField(true, o => o.Employee.EmployeeID.ToString() + " - " + o.Employee.FirstName + " " + o.Employee.LastName, () => GetAllEmployees(baseUri));
c.Add(o => o.ShipVia, true).SetSelectField(true, o => o.Shipper == null ? "" : o.Shipper.ShipperID.ToString() + " - " + o.Shipper.CompanyName, () => GetAllShippers(baseUri));
c.Add(o => o.OrderDate, "OrderCustomDate").Titled(SharedResource.OrderCustomDate).SetInputType(InputType.Week).SetFilterWidgetType("Week").RenderValueAs(o => DateTimeUtils.GetWeekDateTimeString(o.OrderDate)).SetWidth(120);
c.Add(o => o.OrderDate, "OrderCustomDate").Titled(SharedResource.OrderCustomDate).SetInputType(InputType.Week).SetFilterWidgetType("Week").RenderValueAs(o => DateTimeUtils.GetWeekDateTimeString(o.OrderDate)).SetWidth(120).SetCrudWidth(3);
c.Add(o => o.Customer.CompanyName).Titled(SharedResource.CompanyName).SetWidth(250).SetCrudHidden(true).SetReadOnlyOnUpdate(true);
c.Add(o => o.Customer.ContactName).Titled(SharedResource.ContactName).SetWidth(250).SetCrudHidden(true);
c.Add(o => o.Freight).Titled(SharedResource.Freight).Format("{0:F}");
c.Add(o => o.Customer.IsVip).Titled(SharedResource.IsVip).SetWidth(70).Css("hidden-xs").RenderValueAs(o => o.Customer.IsVip ? Strings.BoolTrueLabel : Strings.BoolFalseLabel).SetCrudHidden(true);
c.Add(o => o.RequiredDate, true).Format("{0:yyyy-MM-dd}");
c.Add(o => o.ShippedDate, true).Format("{0:yyyy-MM-dd}");
c.Add(o => o.RequiredDate, true).Format("{0:yyyy-MM-dd}").SetCrudWidth(3);
c.Add(o => o.ShippedDate, true).Format("{0:yyyy-MM-dd}").SetCrudWidth(3);
c.Add(o => o.ShipName, true);
c.Add(o => o.ShipAddress, true);
c.Add(o => o.ShipCity, true);
Expand Down
7 changes: 4 additions & 3 deletions GridBlazorServerSide/ColumnCollections/ColumnCollections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ public static Action<IGridColumnCollection<Order>, IList<Func<object, Task>>, ob
.SetInputType(InputType.Week)
.SetFilterWidgetType("Week")
.RenderValueAs(o => DateTimeUtils.GetWeekDateTimeString(o.OrderDate))
.SetWidth(120);
.SetWidth(120)
.SetCrudWidth(3);

/* Adding "CompanyName" column: */
c.Add(o => o.Customer.CompanyName).Titled(SharedResource.CompanyName)
Expand All @@ -237,10 +238,10 @@ public static Action<IGridColumnCollection<Order>, IList<Func<object, Task>>, ob
.RenderValueAs(o => o.Customer.IsVip ? Strings.BoolTrueLabel : Strings.BoolFalseLabel).SetCrudHidden(true);

/* Adding hidden "RequiredDate" column: */
c.Add(o => o.RequiredDate, true).Format("{0:yyyy-MM-dd}");
c.Add(o => o.RequiredDate, true).Format("{0:yyyy-MM-dd}").SetCrudWidth(3);

/* Adding hidden "ShippedDate" column: */
c.Add(o => o.ShippedDate, true).Format("{0:yyyy-MM-dd}");
c.Add(o => o.ShippedDate, true).Format("{0:yyyy-MM-dd}").SetCrudWidth(3);

/* Adding hidden "ShipName" column: */
c.Add(o => o.ShipName, true);
Expand Down
2 changes: 1 addition & 1 deletion GridBlazorServerSide/GridBlazorServerSide.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>1.7.0</Version>
<Version>1.7.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
8 changes: 8 additions & 0 deletions GridMvc/Columns/GridColumnBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public abstract class GridColumnBase<T> : GridStyledColumn, IGridColumn<T>, ISGr

public string Width { get; set; }

public int CrudWidth { get; set; } = 5;

public bool SortEnabled { get; protected set; }

public string Title { get; set; }
Expand Down Expand Up @@ -125,6 +127,12 @@ IGridColumn<T> IColumn<T>.SetWidth(int width)
return this;
}

IGridColumn<T> IColumn<T>.SetCrudWidth(int width)
{
CrudWidth = width;
return this;
}

public IGridColumn<T> Css(string cssClasses)
{
AddCssClass(cssClasses);
Expand Down
2 changes: 1 addition & 1 deletion GridMvc/GridMvc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<EnableDefaultEmbeddedResourceItems>False</EnableDefaultEmbeddedResourceItems>
<Product>GridMvc</Product>
<PackageId>GridMvcCore</PackageId>
<Version>3.0.0</Version>
<Version>3.0.1</Version>
<Title>GridMvc</Title>
<Description>ASP.NET MVC Grid component</Description>
<Summary>ASP.NET MVC Grid component</Summary>
Expand Down
10 changes: 10 additions & 0 deletions GridShared/Columns/IGridColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ public interface IColumn<T>
/// </summary>
IGridColumn<T> SetWidth(int width);

/// <summary>
/// Sets the width of the column on crud forms
/// </summary>
IGridColumn<T> SetCrudWidth(int width);

/// <summary>
/// Specify additional css class of the column
/// </summary>
Expand Down Expand Up @@ -391,6 +396,11 @@ public interface IColumn
/// </summary>
string Width { get; set; }

/// <summary>
/// Width of the column on crud forms
/// </summary>
int CrudWidth { get; set; }

/// <summary>
/// EncodeEnabled
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion GridShared/GridShared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<LangVersion>8.0</LangVersion>
<Version>3.0.0</Version>
<Version>3.0.1</Version>
<Title>GridShared</Title>
<Description>Support library for GridBlazor and GridMvcCore component libraries</Description>
<Summary>Support library for GridBlazor and GridMvcCore component libraries</Summary>
Expand Down
8 changes: 5 additions & 3 deletions docs/blazor_client/Crud.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ inputType | ```InputType``` enum. Its value can be ```InputType.TextArea```, ```

You can also add components on the CRUD forms using the ```RenderCrudComponentAs<TComponent>``` method. You must define these columns as **Hidden** to show them just on CRUD forms.

You can configure the width of the column input element using the ```SetCrudWidth(int width)``` method. The default value is 5 and you can configure it from 1 to 10.

And finally all columns included in the grid but not in the CRUD forms should be configured as "CRUD hidden" using the ```SetCrudHidden(true)``` method.

**Notes**:
Expand All @@ -284,13 +286,13 @@ This is an example of column definition:
+ o.Employee.FirstName + " " + o.Employee.LastName, path + $"api/SampleData/GetAllEmployees");
c.Add(o => o.ShipVia, true).SetSelectField(true, o => o.Shipper == null ? "" : o.Shipper.ShipperID.ToString()
+ " - " + o.Shipper.CompanyName, path + $"api/SampleData/GetAllShippers");
c.Add(o => o.OrderDate, "OrderCustomDate").Titled(SharedResource.OrderCustomDate).Format("{0:yyyy-MM-dd}");
c.Add(o => o.OrderDate, "OrderCustomDate").Titled(SharedResource.OrderCustomDate).Format("{0:yyyy-MM-dd}").SetCrudWidth(3);
c.Add(o => o.Customer.CompanyName).Titled(SharedResource.CompanyName).SetReadOnlyOnUpdate(true);
c.Add(o => o.Customer.ContactName).Titled(SharedResource.ContactName).SetCrudHidden(true);
c.Add(o => o.Freight).Titled(SharedResource.Freight).Format("{0:F}");
c.Add(o => o.Customer.IsVip).Titled(SharedResource.IsVip).RenderValueAs(o => o.Customer.IsVip ? "Yes" : "No").SetCrudHidden(true);
c.Add(o => o.RequiredDate, true).Format("{0:yyyy-MM-dd}");
c.Add(o => o.ShippedDate, true).Format("{0:yyyy-MM-dd}");
c.Add(o => o.RequiredDate, true).Format("{0:yyyy-MM-dd}").SetCrudWidth(3);
c.Add(o => o.ShippedDate, true).Format("{0:yyyy-MM-dd}").SetCrudWidth(3);
c.Add(o => o.ShipName, true);
c.Add(o => o.ShipAddress, true);
c.Add(o => o.ShipCity, true);
Expand Down
8 changes: 5 additions & 3 deletions docs/blazor_odata/Crud.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ inputType | ```InputType``` enum. Its value can be ```InputType.TextArea```, ```

You can also add components on the CRUD forms using the ```RenderCrudComponentAs<TComponent>``` method. You must define these columns as **Hidden** to show them just on CRUD forms.

You can configure the width of the column input element using the ```SetCrudWidth(int width)``` method. The default value is 5 and you can configure it from 1 to 10.

And finally all columns included in the grid but not in the CRUD forms should be configured as "CRUD hidden" using the ```SetCrudHidden(true)``` method.

**Notes**:
Expand All @@ -220,14 +222,14 @@ This is an example of column definition:
+ " " + o.Employee.LastName, () => GetAllEmployees(baseUri));
c.Add(o => o.ShipVia, true).SetSelectField(true, o => o.Shipper == null ? "" : o.Shipper.ShipperID.ToString() + " - "
+ o.Shipper.CompanyName, () => GetAllShippers(baseUri));
c.Add(o => o.OrderDate, "OrderCustomDate").Titled(SharedResource.OrderCustomDate).Format("{0:yyyy-MM-dd}").SetWidth(120);
c.Add(o => o.OrderDate, "OrderCustomDate").Titled(SharedResource.OrderCustomDate).Format("{0:yyyy-MM-dd}").SetWidth(120).SetCrudWidth(3);
c.Add(o => o.Customer.CompanyName).Titled(SharedResource.CompanyName).SetWidth(250).SetCrudHidden(true).SetReadOnlyOnUpdate(true);
c.Add(o => o.Customer.ContactName).Titled(SharedResource.ContactName).SetWidth(250).SetCrudHidden(true);
c.Add(o => o.Freight).Titled(SharedResource.Freight).Format("{0:F}");
c.Add(o => o.Customer.IsVip).Titled(SharedResource.IsVip).SetWidth(70).Css("hidden-xs")
.RenderValueAs(o => o.Customer.IsVip ? Strings.BoolTrueLabel : Strings.BoolFalseLabel).SetCrudHidden(true);
c.Add(o => o.RequiredDate, true).Format("{0:yyyy-MM-dd}");
c.Add(o => o.ShippedDate, true).Format("{0:yyyy-MM-dd}");
c.Add(o => o.RequiredDate, true).Format("{0:yyyy-MM-dd}").SetCrudWidth(3);
c.Add(o => o.ShippedDate, true).Format("{0:yyyy-MM-dd}").SetCrudWidth(3);
c.Add(o => o.ShipName, true);
c.Add(o => o.ShipAddress, true);
c.Add(o => o.ShipCity, true);
Expand Down
8 changes: 5 additions & 3 deletions docs/blazor_server/Crud.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ inputType | ```InputType``` enum. Its value can be ```InputType.TextArea```, ```

You can also add components on the CRUD forms using the ```RenderCrudComponentAs<TComponent>``` method. You must define these columns as **Hidden** to show them just on CRUD forms.

You can configure the width of the column input element using the ```SetCrudWidth(int width)``` method. The default value is 5 and you can configure it from 1 to 10.

And finally all columns included in the grid but not in the CRUD forms should be configured as "CRUD hidden" using the ```SetCrudHidden(true)``` method.

**Notes**:
Expand All @@ -178,13 +180,13 @@ This is an example of column definition:
+ " - " + o.Employee.FirstName + " " + o.Employee.LastName, employeeService.GetAllEmployees);
c.Add(o => o.ShipVia, true).SetSelectField(true, o => o.Shipper == null ? "" : o.Shipper.ShipperID.ToString()
+ " - " + o.Shipper.CompanyName, shipperService.GetAllShippers);
c.Add(o => o.OrderDate, "OrderCustomDate").Titled(SharedResource.OrderCustomDate).Format("{0:yyyy-MM-dd}");
c.Add(o => o.OrderDate, "OrderCustomDate").Titled(SharedResource.OrderCustomDate).Format("{0:yyyy-MM-dd}").SetCrudWidth(3);
c.Add(o => o.Customer.CompanyName).Titled(SharedResource.CompanyName).SetReadOnlyOnUpdate(true);
c.Add(o => o.Customer.ContactName).Titled(SharedResource.ContactName).SetCrudHidden(true);
c.Add(o => o.Freight).Titled(SharedResource.Freight).Format("{0:F}");
c.Add(o => o.Customer.IsVip).Titled(SharedResource.IsVip).RenderValueAs(o => o.Customer.IsVip ? "Yes" : "No").SetCrudHidden(true);
c.Add(o => o.RequiredDate, true).Format("{0:yyyy-MM-dd}");
c.Add(o => o.ShippedDate, true).Format("{0:yyyy-MM-dd}");
c.Add(o => o.RequiredDate, true).Format("{0:yyyy-MM-dd}").SetCrudWidth(3);
c.Add(o => o.ShippedDate, true).Format("{0:yyyy-MM-dd}").SetCrudWidth(3);
c.Add(o => o.ShipName, true);
c.Add(o => o.ShipAddress, true);
c.Add(o => o.ShipCity, true);
Expand Down
8 changes: 5 additions & 3 deletions docs/dotnetcore_blazor/Crud.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ inputType | ```InputType``` enum. Its value can be ```InputType.TextArea```, ```

You can also add components on the CRUD forms using the ```RenderCrudComponentAs<TComponent>``` method. You must define these columns as **Hidden** to show them just on CRUD forms.

You can configure the width of the column input element using the ```SetCrudWidth(int width)``` method. The default value is 5 and you can configure it from 1 to 10.

And finally all columns included in the grid but not in the CRUD forms should be configured as "CRUD hidden" using the ```SetCrudHidden(true)``` method.

**Notes**:
Expand All @@ -176,13 +178,13 @@ This is an example of column definition:
+ " - " + o.Employee.FirstName + " " + o.Employee.LastName, employeeService.GetAllEmployees);
c.Add(o => o.ShipVia, true).SetSelectField(true, o => o.Shipper == null ? "" : o.Shipper.ShipperID.ToString()
+ " - " + o.Shipper.CompanyName, shipperService.GetAllShippers);
c.Add(o => o.OrderDate, "OrderCustomDate").Titled(SharedResource.OrderCustomDate).Format("{0:yyyy-MM-dd}");
c.Add(o => o.OrderDate, "OrderCustomDate").Titled(SharedResource.OrderCustomDate).Format("{0:yyyy-MM-dd}").SetCrudWidth(3);
c.Add(o => o.Customer.CompanyName).Titled(SharedResource.CompanyName).SetReadOnlyOnUpdate(true);
c.Add(o => o.Customer.ContactName).Titled(SharedResource.ContactName).SetCrudHidden(true);
c.Add(o => o.Freight).Titled(SharedResource.Freight).Format("{0:F}");
c.Add(o => o.Customer.IsVip).Titled(SharedResource.IsVip).RenderValueAs(o => o.Customer.IsVip ? "Yes" : "No").SetCrudHidden(true);
c.Add(o => o.RequiredDate, true).Format("{0:yyyy-MM-dd}");
c.Add(o => o.ShippedDate, true).Format("{0:yyyy-MM-dd}");
c.Add(o => o.RequiredDate, true).Format("{0:yyyy-MM-dd}").SetCrudWidth(3);
c.Add(o => o.ShippedDate, true).Format("{0:yyyy-MM-dd}").SetCrudWidth(3);
c.Add(o => o.ShipName, true);
c.Add(o => o.ShipAddress, true);
c.Add(o => o.ShipCity, true);
Expand Down

0 comments on commit 80ecfdd

Please sign in to comment.