Skip to content

Commit 0285e9d

Browse files
committed
Column example
1 parent 63b8c89 commit 0285e9d

File tree

5 files changed

+62
-3
lines changed

5 files changed

+62
-3
lines changed

Griddly/Controllers/ExampleController.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ namespace Griddly.Controllers
99
{
1010
public partial class ExampleController : Controller
1111
{
12+
public ActionResult Columns()
13+
{
14+
return View("Example", new ExampleModel()
15+
{
16+
Title = "Columns Example",
17+
GridAction = "ColumnsGrid",
18+
GridView = "ColumnsGrid.cshtml",
19+
Description = "Griddly column helpers offer several ways to quickly define your table structure."
20+
});
21+
}
22+
1223
public ActionResult Filters()
1324
{
1425
return View("Example", new ExampleModel()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Griddly.Models;
2+
using Griddly.Mvc;
3+
using Griddly.Mvc.Results;
4+
using System.Linq;
5+
using System.Web.Mvc;
6+
7+
namespace Griddly.Controllers
8+
{
9+
public partial class ExampleController : Controller
10+
{
11+
public GriddlyResult ColumnsGrid()
12+
{
13+
IQueryable<TestGridItem> query = _testData;
14+
15+
return new QueryableResult<TestGridItem>(query);
16+
}
17+
}
18+
}

Griddly/Griddly.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@
126126
<Compile Include="App_Start\FilterConfig.cs" />
127127
<Compile Include="App_Start\RouteConfig.cs" />
128128
<Compile Include="Controllers\ExampleController.cs" />
129-
<Compile Include="Controllers\Examples\FiltersGrids.cs">
129+
<Compile Include="Controllers\Examples\ColumnsGrid.cs">
130+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
131+
</Compile>
132+
<Compile Include="Controllers\Examples\FiltersGrid.cs">
130133
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
131134
</Compile>
132135
<Compile Include="Controllers\HomeController.cs" />
@@ -278,6 +281,7 @@
278281
<Content Include="Views\Home\Test2Grid.cshtml" />
279282
<Content Include="Views\Example\Example.cshtml" />
280283
<Content Include="Views\Example\FiltersGrid.cshtml" />
284+
<Content Include="Views\Example\ColumnsGrid.cshtml" />
281285
</ItemGroup>
282286
<ItemGroup>
283287
<ProjectReference Include="..\Griddly.Mvc\Griddly.Mvc.csproj">
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
@{
2+
var gridSettings = new GriddlySettings<TestGridItem>()
3+
{
4+
PageSize = 20,
5+
RowClickUrl = x => "http://microsoft.com",
6+
EmptyGridMessageTemplate =@<text><div class="alert alert-warning">@item.Settings.EmptyGridMessage</div></text>,
7+
EmptyGridMessage = "Sorry, no records were found"
8+
};
9+
10+
gridSettings
11+
.Column(x => x.Id)
12+
.Column(x => x.FirstName, "First Name")
13+
.Column(x => x.LastName, "Last Name", defaultSort: SortDirection.Ascending, className: "custom-style")
14+
.Column(x => x.Address)
15+
.Column(x => x.City)
16+
.Column(x => x.State)
17+
.Column(x => x.PostalCode, "Zip")
18+
.Column(x => x.Quantity)
19+
.Column(x => x.Total, format: "c")
20+
.Column(x => x.Date, htmlAttributes: x => new { data_date = x.Date })
21+
.Column("Approved", template: x => x.IsApproved ? "YES" : "NO!");
22+
}
23+
24+
<style>
25+
.custom-style { font-weight: bold; }
26+
</style>
27+
28+
@Html.Griddly(gridSettings)

Griddly/Views/Example/FiltersGrid.cshtml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
@{
2-
ViewBag.Title = "TestGrid";
3-
42
List<SelectListItem> groupedList = new List<SelectListItem>()
53
{
64
new SelectListItemGroup()

0 commit comments

Comments
 (0)