| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<mvc.Models.Customer>>" %>
<%@ Import Namespace="mvc.Helpers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Customers
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript" language="javascript">
function makeLink(celDiv)
{
$(celDiv).html('<a href="Customer/Edit?customerId=' + $(celDiv).html() + '">' + $(celDiv).html() + '</a>');
}
function test(com, grid) {
if (com == 'Delete') {
var itemsSelected = $('.trSelected', grid).length;
if (itemsSelected > 0) {
if (confirm('Delete ' + itemsSelected + ' items?')) {
var items = $('.trSelected', grid);
var itemList = '';
for (i = 0; i < items.length; i++) {
itemList += items[i].id.substr(3) + ",";
}
$.ajax({ type: "POST", dataType: "json", url: "JSon/DeleteCustomer", data: "customerIds=" + itemList, success: function(data) { alert(data.Message); $("#tableCustomer").flexReload(); } });
}
}
else {
return false;
}
}
else if (com == 'Add')
document.location = "/Customer/Create";
}
</script>
<div>
<%=Html.FlexiGrid(
new FlexiGridParameters { TableContainerName = "tableCustomer",
Title = "Customers",
Url = "JSon/GetCustomers",
Width = 300,
Height = 400,
Columns = new FlexiGridColumn[]
{
new FlexiGridColumn("Customer Id","CustomerId",50,true,Alignment.Left, "makeLink"),
new FlexiGridColumn("Company Name","CompanyName",100,true,Alignment.Left),
new FlexiGridColumn("Contact Name","ContactName",100,true,Alignment.Left),
new FlexiGridColumn("Address","Address",100,true,Alignment.Left),
new FlexiGridColumn("City","City",100,true,Alignment.Left),
new FlexiGridColumn("Contact Title","ContactTitle",100,true,Alignment.Left),
new FlexiGridColumn("Country","Country",100,true,Alignment.Left),
new FlexiGridColumn("Fax","Fax",100,true,Alignment.Left),
new FlexiGridColumn("Phone","Phone",100,true,Alignment.Left),
new FlexiGridColumn("Postal Code","PostalCode",100,true,Alignment.Left),
new FlexiGridColumn("Region","Region",100,true,Alignment.Left)
},
Buttons = new FlexigridButton[] {
new FlexigridButton("Add","add","test"),
new FlexigridButton("Delete","delete","test")
},
SearchItems = new FlexiGridSearchItem[] {
new FlexiGridSearchItem("Customer Id","CustomerId"),
new FlexiGridSearchItem("Contact Name","ContactName")
},
AllowPaging = true,
PageSize = 10,
ShowTableToggleButton = true
}
) %>
</div>
</asp:Content> |