Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
141060 | Nov 20,2018 11:56 PM UTC | Nov 27,2018 05:03 AM UTC | ASP.NET MVC | 7 |
![]() |
Tags: Grid |
<style type="text/css">
.required::after {
content: '*';
margin-right: 4px;
color: red;
}
</style>
@(Html.EJ().Grid<object>("Editing")
.Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.dataSource).UpdateURL("InlineUpdate").InsertURL("InlineInsert").RemoveURL("InlineDelete").Adaptor(AdaptorType.RemoteSaveAdaptor))
.EnableAltRow()
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.InlineFormTemplate).InlineFormTemplateID("#template"); })
.AllowPaging()
.ToolbarSettings(toolbar =>
{
toolbar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.Add);
items.AddTool(ToolBarItems.Edit);
items.AddTool(ToolBarItems.Delete);
items.AddTool(ToolBarItems.Update);
items.AddTool(ToolBarItems.Cancel);
});
})
.Columns(col =>
{
. . . . . .
})
.ClientSideEvents(eve => { eve.ActionComplete("complete"); })
)
<script id="template" type="text/template">
<b>Order Details</b>
<table cellspacing="10">
<tr>
<td class="required" style="text-align: right;">
Order ID
</td>
<td style="text-align: left">
<input id="OrderID" name="OrderID" value="{{: OrderID}}" disabled="disabled" class="e-field e-ejinputtext valid e-disable"
style="text-align: right; width: 116px; height: 28px" />
</td>
<td class="required" style="text-align: right;">
Customer ID
</td>
<td style="text-align: left">
<input id="CustomerID" name="CustomerID" value="{{: CustomerID}}" class="e-field e-ejinputtext valid"
style="width: 116px; height: 28px" />
</td>
</tr>
<tr>
<td class="required" style="text-align: right;">
Freight
</td>
<td style="text-align: left">
<input type="text" id="Freight" name="Freight" value="{{:Freight}}" />
</td>
<td class="required" style="text-align: right;">
Ship Country
</td>
<td style="text-align: left">
<select id="ShipCountry" name="ShipCountry">
<option value="Argentina">Argentina</option>
<option value="Austria">Austria</option>
<option value="Belgium">Belgium</option>
<option value="Brazil">Brazil</option>
<option value="Canada">Canada</option>
<option value="Denmark">Denmark</option>
<option value="Finland">Finland</option>
<option value="France">France</option>
<option value="Germany">Germany</option>
<option value="Ireland">Ireland</option>
<option value="Italy">Italy</option>
<option value="Mexico">Mexico</option>
<option value="Norway">Norway</option>
<option value="Poland">Poland</option>
<option value="Portugal">Portugal</option>
<option value="Spain">Spain</option>
<option value="Sweden">Sweden</option>
<option value="Switzerland">Switzerland</option>
<option value="UK">UK</option>
<option value="USA">USA</option>
<option value="Venezuela">Venezuela</option>
</select>
</td>
</tr>
<tr>
<td class="required" style="text-align: right;">
Ship City
</td>
<td style="text-align: left">
<input id="ShipCity" name="ShipCity" value="{{: ShipCity}}" class="e-field e-ejinputtext valid"
style="width: 116px; height: 28px" />
</td>
<td style="text-align: right;">
Ship Name
</td>
<td class="required" style="text-align: left">
<input id="ShipName" name="ShipName" value="{{: ShipName}}" class="e-field e-ejinputtext valid"
style="width: 116px; height: 28px" />
</td>
</tr>
<tr>
<td class="required" style="text-align: right;">
Ship Address
</td>
<td style="text-align: left">
<textarea id="ShipAddress" name="ShipAddress" class="e-ejinputtext" value="{{: ShipAddress}}">{{: ShipAddress}}</textarea>
</td>
</tr>
</table>
</script> |
|
<style type="text/css">
.required::after {
content: '*';
margin-right: 4px;
color: red;
}
</style>
@(Html.EJ().Grid<OrdersView>("FlatGrid")
.Datasource((IEnumerable<object>)ViewBag.datasource)
.ClientSideEvents(events =>{
events.ActionComplete("complete");
})
.Columns(col =>{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add();
. . .
}))
<script>
function complete(args) {
if ((args.requestType == "beginedit" || args.requestType == "add")) {
this.element.find("#GridEditForm").find(".e-label").addClass("required"); // GridID followed with EditForm
}
}
</script>
|
<style type="text/css">
.required::after {
content: '*';
margin-right: 4px;
color: red;
}
</style>
<div id="ControlRegion">
@(Html.EJ().Grid<object>("FlatGrid")
…….
.ClientSideEvents(e => e.ActionComplete("complete"))
………………
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Width(75).ValidationRules(v => v.AddRule("required", true).AddRule("number", true)).Add();
col.Field("CustomerID").HeaderText("Customer ID").Width(80).ValidationRules(v => v.AddRule("required", true)).Add();
……………….
}))
</div>
<script>
function complete(args) {
if ((args.requestType == "beginedit" || args.requestType == "add")) {
for (var i = 0; i < this.model.columns.length; i++) {
if (!ej.isNullOrUndefined(this.model.columns[i].validationRules)) {
if (this.model.columns[i].validationRules.required)
$(this.element.find("#FlatGridEditForm").find(".e-label")[i]).addClass("required"); // GridID followed with EditForm
}
}
}
}
</script>
|
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.