<script type="text/javascript">
if ($("#cars").data("ejDropDownList").getSelectedValue() == undefined) {
var gridObj = $("#GridParameters").ejGrid("instance");
gridObj.option({toolbarSettings: { showToolbar: false }}) // using setModel method change the visibility of the toolbar.
}
</script>
|
@(Html.EJ().Grid<Object>("FlatGrid")
….
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).ValidationRules(v => v.AddRule("required",true)).Add();
…………..
}))
|
$(function () {
……………..
$.validator.addMethod("customRegex", function (value, element, params) {
if (element.value.length == params) // the value 5 is compared with the entered text length
return true;
return false;
}, "Customer ID must be 5 characters");
@(Html.EJ().Grid<Object>("FlatGrid")
.Datasource((IEnumerable<object>)ViewBag.DataSource)
.AllowPaging()
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
.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 =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Add();
col.Field("CustomerID").HeaderText("Customer ID").ValidationRules(v => v.AddRule("customRegex", 5)).Add(); // the value 5 is the params here.
………….
}))
|
@(Html.EJ().Grid("GridParameters")
……………………..
.AllowSearching()
.SearchSettings(search =>
{
search.Fields(field =>
{
field.Add("UserID");
field.Add("UserName");
});
search.Key("Alex");
})
.Columns(col =>
{
……………
)
|