<ej:Grid ID="OrdersGrid" runat="server" AllowPaging="True" AllowSorting="True" OnServerEditRow="EditEvents_ServerEditRow" AllowSelection="true" Selectiontype="Multiple"
OnServerAddRow="EditEvents_ServerAddRow" OnServerDeleteRow="EditEvents_ServerDeleteRow">
<ClientSideEvents ActionComplete="complete" EndAdd="endAdd" EndDelete="endDelete" EndEdit="endEdit"
RecordDoubleClick="doubleClick" ContextClick="Click" CellSelected="cellSelected" />
<SelectionSettings SelectionMode="cell"/>
<ContextMenuSettings EnableContextMenu="true"></ContextMenuSettings>
<Columns>
<ej:Column Field="OrderID" HeaderText=" Order ID" IsPrimaryKey="True" TextAlign="Right" Width="75">
<ValidationRule>
<ej:KeyValue Key="required" Value="true" />
<ej:KeyValue Key="number" Value="true" />
</ValidationRule>
</ej:Column>
<ej:Column Field="ShipCountry" HeaderText="Country" Width="80" EditType="DropdownEdit">
</ej:Column>
</Columns>
<EditSettings AllowEditing="True" AllowAdding="True" AllowDeleting="True"></EditSettings>
<ToolbarSettings ShowToolbar="True" ToolbarItems="add,edit,delete,update,cancel"></ToolbarSettings>
</ej:Grid>
<asp:SqlDataSource ID="SqlData" runat="server" ConnectionString="<%$ ConnectionStrings:NORTHWNDConnectionString %>"
SelectCommand="SELECT * FROM [Orders]"></asp:SqlDataSource>
serverside:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["NORTHWNDConnectionString"].ToString());
dt = new DataTable("Order");
SqlCommand cmd = new SqlCommand();
cmd.Connection = myConnection;
cmd.CommandText = "select * from Orders";
cmd.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
if (myConnection.State == ConnectionState.Closed)
{
myConnection.Open();
}
da.Fill(dt);
Session["SqlDataSource"] = dt;
dataBind();
}
|
<ej:Grid ID="OrdersGrid" runat="server" AllowPaging="True" AllowSorting="True" OnServerEditRow="EditEvents_ServerEditRow" AllowSelection="true" Selectiontype="Multiple"/>
<SelectionSettings SelectionMode="cell"/>
<ContextMenuSettings EnableContextMenu="true"></ContextMenuSettings>
<Columns>
<ej:Column Field="OrderID" HeaderText=" Order ID" IsPrimaryKey="True" TextAlign="Right" Width="75">
<ValidationRule>
<ej:KeyValue Key="required" Value="true" />
<ej:KeyValue Key="number" Value="true" />
</ValidationRule>
</ej:Column>
. . .
</ej:Grid>
<asp:SqlDataSource ID="SqlData" runat="server" ConnectionString="<%$ ConnectionStrings:NORTHWNDConnectionString %>"
SelectCommand="SELECT * FROM [Orders]"></asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
|
<ej:Grid ID="OrdersGrid" runat="server" AllowPaging="True" AllowSorting="True" OnServerEditRow="EditEvents_ServerEditRow" AllowSelection="true" Selectiontype="Multiple"
OnServerAddRow="EditEvents_ServerAddRow" OnServerDeleteRow="EditEvents_ServerDeleteRow">
<ClientSideEvents
ContextClick="Click" CellSelected="cellSelected" />
<SelectionSettings SelectionMode="cell"/>
<ContextMenuSettings EnableContextMenu="true"></ContextMenuSettings>
<Columns>
. . .
</Columns>
<script>
var records = [];
function cellSelected(args) {
records.push(args.data);
}
function Click(args) {
if (args.text == "Delete Record") {
for (var del = 0; del < records.length; del++) {
this.deleteRecord("OrderID", records[del]);
}
}
args.cancel = true
}
</script>
|