|
<div>
<ej:Grid ID="OrdersGrid" runat="server" AllowScrolling="true" AllowPaging="True">
<ScrollSettings FrozenColumns="1" />
</ej:Grid>
</div>
[aspx.cs]
List<Orders> order = new List<Orders>();
List<string> str = new List<string>();
List<EmployeeInfo> Info = new List<EmployeeInfo>();
protected void Page_Load(object sender, EventArgs e)
{
str.Add("<ul><li>Lorem Ipsum is simply dummy text of the printing and typesetting </li><li>Lorem Ipsum is simply dummy text of the printing and typesetting </li><li>Lorem Ipsum is simply dummy text of the printing and typesetting (3rd party integration)</li><li>Lorem Ipsum is simply dummy text of the printing and typesetting </li><li>Lorem Ipsum is simply dummy text of the printing and typesetting </li></ul>");
str.Add("<ul><li>Lorem Ipsum is simply dummy text of the printing and typesetting </li><li>Lorem Ipsum is simply dummy text of the printing and typesetting </li><li>Lorem Ipsum is simply dummy text of the printing and typesetting (3rd party integration)</li><li>Lorem Ipsum is simply dummy text of the printing and typesetting </li><li>Lorem Ipsum is simply dummy text of the printing and typesetting </li></ul>");
BindDataSource();
}
private void BindDataSource()
{
int code = 10000;
Info.Add(new EmployeeInfo(""));
for (int i = 1; i < 10; i++)
{
order.Add(new Orders(code + 1, "ALFKI", str, i + 0, 2.3 * i, new DateTime(1991, 05, 15), "Berlin"));
order.Add(new Orders(code + 2, "ANATR", str, i + 2, 3.3 * i, new DateTime(1990, 04, 04), "Madrid"));
order.Add(new Orders(code + 3, "ANTON", str, i + 1, 4.3 * i, new DateTime(1957, 11, 30), "Cholchester"));
order.Add(new Orders(code + 4, "BLONP", str, i + 3, 5.3 * i, new DateTime(1930, 10, 22), "Marseille"));
order.Add(new Orders(code + 5, "BOLID", str, i + 4, 6.3 * i, new DateTime(1953, 02, 18), "Tsawassen")); code += 5;
}
this.OrdersGrid.DataSource = order;
this.OrdersGrid.DataBind();
} |
|
[aspx.cs]
private void BindDataSource()
{
int code = 10000;
Info.Add(new EmployeeInfo(""));
for (int i = 1; i < 10; i++)
{
order.Add(new Orders(code + 1, "ALFKI", str, i + 0, 2.3 * i, new DateTime(1991, 05, 15), "Berlin"));
-------------------------
}
List<Column> col = new List<Column>();
col.Add(new Column() { Field = "OrderID", HeaderText = "OrderID", Width = 80, });
col.Add(new Column() { Field = "CustomerID", HeaderText = "CustomerID", Width = 80, });
col.Add(new Column() { Field = "EmployeeID", HeaderText = "EmployeeID", Width = 80, });
------------------
…...
this.OrdersGrid.DataSource = order;
this.OrdersGrid.Model.Columns = col;
this.OrdersGrid.DataBind();
} |
|
[aspx.cs]
List<Column> col = new List<Column>();
col.Add(new Column() { Field = "OrderID", HeaderText = "OrderID", Width = 80, });
col.Add(new Column() { Field = "CustomerID", HeaderText = "CustomerID", Width = 80, EditTemplate = new EditTemplate() { Create = "create", Read = "read", Write = "write" } });
col.Add(new Column() { Field = "EmployeeID", HeaderText = "EmployeeID", Width = 80, });
col.Add(new Column() { Field = "Employee", HeaderText = "Employee", Width = 80, });
col.Add(new Column() { Field = "Freight", HeaderText = "Freight", Width = 80 });
col.Add(new Column() { Field = "OrderDate", HeaderText = "OrderDate", Width = 300, });
col.Add(new Column() { Field = "ShipCity1", HeaderText = "ShipCity1", Width = 80, }
[aspx]
<div>
<ej:Grid ID="OrdersGrid" MinWidth="900" runat="server" AllowScrolling="true" AllowPaging="true" >
<ScrollSettings Width="400" FrozenColumns="1" />
<EditSettings AllowEditing="true" />
</ej:Grid>
</div>
<script>
function create() {
return $("<input>");
}
function write(args) {
obj = $('#<%= OrdersGrid.ClientID %>').ejGrid('instance');
var data = ej.DataManager(obj.model.dataSource).executeLocal(new ej.Query().select("CustomerID"));
args.element.ejAutocomplete({ width: "100%", dataSource: data, enableDistinct: true, value: args.rowdata !== undefined ? args.rowdata["CustomerID"] : "" });
}
function read(args) {
args.ejAutocomplete('suggestionList').css('display', 'none');
return args.ejAutocomplete("getValue");
}
$(function () {
$('#<%= OrdersGrid.ClientID %>').keyup(function (e) {
if ( e.keyCode == 40 && $(e.target).hasClass("e-autocomplete")) {
var gridid = $('#<%= OrdersGrid.ClientID %>').attr("id");
var autocomp = $("#" + gridid + "CustomerID").ejAutocomplete("instance")
if (autocomp.getValue() != "" && autocomp.getActiveText() != "No suggestions")
$(e.target).val(autocomp.getActiveText());
}
});
});
</script>
|