<ej:Grid ID="OrdersGrid" runat="server" AllowPaging="True" AllowTextWrap="true" OnServerEditRow="EditEvents_ServerEditRow"
OnServerAddRow="EditEvents_ServerAddRow" OnServerDeleteRow="EditEvents_ServerDeleteRow">
<ClientSideEvents ActionComplete="complete" EndAdd="endAdd" EndDelete="endDelete" EndEdit="endEdit" />
<Columns>
<ej:Column Field="OrderID" HeaderText="Order ID" IsPrimaryKey="true" TextAlign="Right" Width="80">
<ValidationRule>
<ej:KeyValue Key="required" Value="true" />
<ej:KeyValue Key="number" Value="true" />
</ValidationRule>
</ej:Column>
<ej:Column Field="CustomerID" HeaderText="Customer ID" Width="80">
<ValidationRule>
<ej:KeyValue Key="required" Value="true" />
<ej:KeyValue Key="minlength" Value="3" />
</ValidationRule>
</ej:Column>
<ej:Column Field="EmployeeID" HeaderText="Employee ID" TextAlign="Right" EditType="DropdownEdit" Width="80">
</ej:Column>
<ej:Column Field="Freight" HeaderText="Freight" TextAlign="Right" Width="80" Format="{0:C}" EditType="NumericEdit">
<NumericEditOptions DecimalPlaces="2"></NumericEditOptions>
</ej:Column>
<ej:Column Field="ShipCountry" HeaderText="ShipCountry" Width="90" EditType="DropdownEdit" />
<ej:Column Field="ShipName" HeaderText="ShipName" Width="180" />
</Columns>
<EditSettings AllowEditing="True" AllowAdding="True" AllowDeleting="True"></EditSettings>
<ToolbarSettings ShowToolbar="True" ToolbarItems="add,edit,delete,update,cancel"></ToolbarSettings>
<ClientSideEvents ActionComplete="oncomplete" />
</ej:Grid>
<script type="text/javascript">
var data = JSON.parse('<%= new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(this.data)%>'); // to get the dataSource from server.
function oncomplete(args) {
var id = this.element.attr("id");
if (args.requestType == "add" || args.requestType == "beginedit") {
//GridID + ColumnName
var ddl = $("#" + id + "EmployeeID").ejDropDownList("instance");
ddl.setModel({ dataSource: data }); // update the new dataSource
}
}
</script>
C#
public IEnumerable data;
List<Orders> order = new List<Orders>();
protected void Page_Load(object sender, EventArgs e)
{
BindDataSource();
this.data = new List<int>() {10,11,12,13,14,15,16,19,20,200,400 };
Session["InlineEditDataSource"] = order;
} |