Skip to content

Commit

Permalink
Moved Customer object to Shared project
Browse files Browse the repository at this point in the history
  • Loading branch information
csharpfritz committed Mar 13, 2020
1 parent dd15ae4 commit 8f5716f
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 128 deletions.
@@ -1,49 +1,12 @@
@page "/ControlSamples/GridView/AutoGeneratedColumns"

<h2>GridView Default AutoGeneratedColumns</h2>

<Nav />

<GridView ItemType="Customer"
DataKeyNames="CustomerID"
SelectMethod="GetCustomers"
AutogenerateColumns="true">
</GridView>

@code{
public IQueryable<Customer> GetCustomers(int maxRows, int startRowIndex, string sortByExpression, out int totalRowCount)
{
var customers = new List<Customer>();
var c1 = new Customer
{
CustomerID = 1,
FirstName = "John",
LastName = "Smith",
CompanyName = "Virus"
};

var c2 = new Customer
{
CustomerID = 2,
FirstName = "Jose",
LastName = "Rodriguez",
CompanyName = "Boring"
};


var c3 = new Customer
{
CustomerID = 3,
FirstName = "Jason",
LastName = "Ramirez",
CompanyName = "Fun Machines"
};

customers.Add(c1);
customers.Add(c2);
customers.Add(c3);

totalRowCount = customers.Count();
return customers.AsQueryable();
}
}
@page "/ControlSamples/GridView/AutoGeneratedColumns"

<h2>GridView Default AutoGeneratedColumns</h2>

<Nav />

<GridView ItemType="Customer"
DataKeyNames="CustomerID"
SelectMethod="Customer.GetCustomers"
AutogenerateColumns="true">
</GridView>

This file was deleted.

@@ -1,61 +1,24 @@
@page "/ControlSamples/GridView"

<h2>GridView Default Example</h2>

<Nav />

<GridView ItemType="Customer"
AutogenerateColumns="false"
DataKeyNames="CustomerID"
SelectMethod="GetCustomers"
EmptyDataText="No data available">
<Columns>
<BoundField DataField="CustomerID" HeaderText="ID" />
<BoundField DataField="CompanyName" HeaderText="CompanyName" />
<BoundField DataField="FirstName" HeaderText="FirstName"/>
<BoundField DataField="LastName" HeaderText="LastName"/>
<TemplateField>
<ItemTemplate Context="Item">
<button type="button">Click Me! @Item.FirstName</button>
</ItemTemplate>
</TemplateField>
</Columns>
</GridView>

@code{
public IQueryable<Customer> GetCustomers(int maxRows, int startRowIndex, string sortByExpression, out int totalRowCount)
{
var customers = new List<Customer>();
var c1 = new Customer
{
CustomerID = 1,
FirstName = "John",
LastName = "Smith",
CompanyName = "Virus"
};

var c2 = new Customer
{
CustomerID = 2,
FirstName = "Jose",
LastName = "Rodriguez",
CompanyName = "Boring"
};


var c3 = new Customer
{
CustomerID = 3,
FirstName = "Jason",
LastName = "Ramirez",
CompanyName = "Fun Machines"
};

customers.Add(c1);
customers.Add(c2);
customers.Add(c3);

totalRowCount = customers.Count();
return customers.AsQueryable();
}
}
@page "/ControlSamples/GridView"

<h2>GridView Default Example</h2>

<Nav />

<GridView ItemType="Customer"
AutogenerateColumns="false"
DataKeyNames="CustomerID"
SelectMethod="Customer.GetCustomers"
EmptyDataText="No data available">
<Columns>
<BoundField DataField="CustomerID" HeaderText="ID" />
<BoundField DataField="CompanyName" HeaderText="CompanyName" />
<BoundField DataField="FirstName" HeaderText="FirstName"/>
<BoundField DataField="LastName" HeaderText="LastName"/>
<TemplateField>
<ItemTemplate Context="Item">
<button type="button">Click Me! @Item.FirstName</button>
</ItemTemplate>
</TemplateField>
</Columns>
</GridView>

55 changes: 55 additions & 0 deletions samples/SharedSampleObjects/Models/Customer.cs
@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace SharedSampleObjects.Models
{
public class Customer
{
public int CustomerID { get; set; }

public string FirstName { get; set; }

public string LastName { get; set; }

public string CompanyName { get; set; }

public static IQueryable<Customer> GetCustomers(int maxRows, int startRowIndex, string sortByExpression, out int totalRowCount)
{
var customers = new List<Customer>();
var c1 = new Customer
{
CustomerID = 1,
FirstName = "John",
LastName = "Smith",
CompanyName = "Virus"
};

var c2 = new Customer
{
CustomerID = 2,
FirstName = "Jose",
LastName = "Rodriguez",
CompanyName = "Boring"
};


var c3 = new Customer
{
CustomerID = 3,
FirstName = "Jason",
LastName = "Ramirez",
CompanyName = "Fun Machines"
};

customers.Add(c1);
customers.Add(c2);
customers.Add(c3);

totalRowCount = customers.Count();
return customers.AsQueryable();
}

}
}

0 comments on commit 8f5716f

Please sign in to comment.