I would like to setup a validation rule that would conditionally be applied. For example
I have three fields
Status: Enum field (​pending, approved, denied)
Denied Code: (price, qty, misc..., ect...)
Comment (Long text)
So if the Status is equal to denied I want the Denied Code and Comment to require an update otherwise ignore them. Is this possible? and if so how would I go about doing this? Also the value of the Denied Code must not equal none.
My Index page:
<style> .cont { padding-right: 10%; padding-left: 10%; margin-right: auto; margin-left: auto;}</style><div class="cont"> @(Html.Kendo().Grid<Portal.Model.DAX.PurchaseJournalTransaction>() .Name("grid") .Columns(columns => { columns.Bound(c => c.PurchId).Title("Order Id").Width(120); columns.Bound(c => c.LineNum).Title("Line").Width(80).Hidden(true).IncludeInMenu(true); columns.Bound(c => c.ItemId).Width(120); columns.Bound(c => c.ExternalItemId).Title("External Id").Width(120); columns.Bound(c => c.Name).Width(400); columns.Bound(c => c.DeliveryDate).Width(140).Format("{0:MM/dd/yy}"); columns.Bound(c => c.PurchUnit).Width(75).Title("Unit"); columns.Bound(c => c.Quantity).Width(120).Format("{0:#,##0}"); columns.Bound(c => c.PurchasePrice).Width(100).Title("Price").Format("{0:$ #,##0.00}"); columns.Bound(c => c.LineAmount).Width(160).Hidden(true).IncludeInMenu(true).Format("{0:$ #,##0.00}"); columns.Bound(c => c.LineDiscount).Width(80).Hidden(true).IncludeInMenu(true); columns.Bound(c => c.LinePercent).Width(80).Hidden(true).IncludeInMenu(true); columns.Bound(c => c.ApprovalStatus).Width(130).EditorTemplateName("ApprovalStatusEditor").Title("Status"); columns.ForeignKey(c => c.ApprovalReasonId, (System.Collections.IEnumerable)ViewData["ApprovalReason"], "Id", "Description").Width(350).Title("Denied Code"); }) .ToolBar(toolbar => { toolbar.Excel(); toolbar.Save(); }) .Editable(editable => editable.Mode(GridEditMode.InCell)) .Pageable(p => p.PageSizes(true).PageSizes(new int[] {20,50,100,1000})) .Navigatable() .Filterable(filtering => filtering.Enabled(true)) .Groupable() .Sortable(s => { s.SortMode(GridSortMode.MultipleColumn); s.AllowUnsort(true); }) .ColumnMenu() .Scrollable(scrollable => { scrollable.Enabled(true); scrollable.Height(700); }) .DataSource(dataSource => dataSource .Ajax() .PageSize(20) .Model(model => { model.Id(p => p.CompanyId); model.Field(c => c.PurchId).Editable(false); model.Field(c => c.LineNum).Editable(false); model.Field(c => c.ItemId).Editable(false); model.Field(c => c.ExternalItemId).Editable(false); model.Field(c => c.Name).Editable(false); model.Field(c => c.CurrencyCode).Editable(false); model.Field(c => c.PriceUnit).Editable(false); model.Field(c => c.Quantity).Editable(false); model.Field(c => c.PurchUnit).Editable(false); model.Field(c => c.PurchasePrice).Editable(false); model.Field(c => c.DeliveryDate).Editable(false); model.Field(c => c.LineAmount).Editable(false); model.Field(c => c.LineDiscount).Editable(false); model.Field(c => c.LinePercent).Editable(false); }) .Read(read => read.Action("PurchaseJournalTransactions_Read", "Approval")) .Update(update => update.Action("PurchaseJournalTransactions_Update", "Approval")) ) ) <br /></div>Hello, I just started working with the product. I created a grid using the MVC control. Also, the grid is using a custom pop up form when editing/creating a record.
Inside that custom form, I added a multiselect control. The control should reference values stored in a child table from the record, basically I want to store multiples agencies a person can belong to. The model have a reference to the child table.
When submitting the form, the entity object knows that I ​selected X amount of companies, but I cant get to the values. What is the best way of doing this for a child table?
<label for="Agency" class="required col-sm-3 control-label" style="text-align:left;margin-right:-55px">Insurance Companies</label>
@(Html.Kendo().MultiSelect()
.Name("tblAgentInsurers")
.DataTextField("InsuranceAgencyName")
.DataValueField("InsuranceAgencyID")
.Placeholder("Select agencies...")
.HtmlAttributes(new { @class = "col-sm-2 form-control", style = "width:70%; height:auto; min-height: 34px;" })
.AutoBind(false)
.Filter(FilterType.Contains)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetAgencies", "Agents");
})
.ServerFiltering(true);
})
)​
Hi
I have textbox, a button and a Grid in my screen, i am binding data to it on a button click with the textbox input.
If the user clicks the button again with different inputs, i have to go to DB, get data and append the new data to the existing Grid data.
I should not lose the existing data and i need to append new data to the same grid I should be able to call the same URL to get data.
Please let me know how I can achieve this.
Sample Code:
<input type="text" class="k-textbox"/>
<button id="btnAdd">Add</button></td>
<div id="grid"></div>
<script>
$("#btnAdd").on('click', function () {
$("#grid").kendoGrid({
dataSource: {
type: "json",
transport: {
read:
{
url: // my url with textbox inputs,
cache: false
}
},
schema: {
model: {
fields: {
ID: {type: "string"},
Name: {type: "String"}
}
}
},
columns: [
//{ hidden: true, field: "AssetID", editable: false },
{ template: "<input type='checkbox' class='checkbox' />" },
{ field: "ID"},
{ field: "Name"}]
}).data("kendoGrid");
});
});
</script>
I have a Project that uses Entity Framework as it data source, and I have a Kendo grid for that data set.
The Grid populates find while running from my development box but when I publish it; it just spins and nothing happens no error "nothing".
I have confirmed that the published page is talking to the Database as I can create a normal Model and for loop and return the data into a default div list. The query generated for the page does take about 3-4 seconds to process which I really can't speed up due to the size of the tables, it only returns though at most 100 records.
Below is the Index page
<style> .cont { padding-right: 10%; padding-left: 10%; margin-right: auto; margin-left: auto;}</style><div class="cont"> @(Html.Kendo().Grid<Portal.Model.DAX.PurchaseJournalTransaction>() .Name("grid") .Columns(columns => { columns.Bound(c => c.PurchId); columns.Bound(c => c.LineNum).Visible(false); columns.Bound(c => c.ItemId).Width(100); columns.Bound(c => c.ExternalItemId); columns.Bound(c => c.Name); columns.Bound(c => c.DeliveryDate).Format("{0:MM/dd/yy}"); columns.Bound(c => c.CurrencyCode).Visible(false); columns.Bound(c => c.PriceUnit).Visible(false); columns.Bound(c => c.Quantity).Format("{0:#,##0}"); columns.Bound(c => c.PurchUnit).Locked(); columns.Bound(c => c.PurchasePrice).Format("{0:$#,##0.00}"); columns.Bound(c => c.PurchaseMarkup).Visible(false); columns.Bound(c => c.DiscountPercentage).Visible(false); columns.Bound(c => c.DiscountAmount).Visible(false); columns.Bound(c => c.LineAmount).Visible(false); columns.Bound(c => c.Dimension1).Visible(false); columns.Bound(c => c.Dimension2).Visible(false); columns.Bound(c => c.Dimension3).Visible(false); columns.Bound(c => c.TaxAmount).Visible(false); columns.Bound(c => c.TaxWriteCode).Visible(false); columns.Bound(c => c.MultiLineDiscount).Visible(false); columns.Bound(c => c.MultiLinePercent).Visible(false); columns.Bound(c => c.LineDiscount).Visible(false); columns.Bound(c => c.LinePercent).Visible(false); columns.Bound(c => c.TaxGroup).Visible(false); columns.Bound(c => c.TaxItemGroup).Visible(false); columns.Bound(c => c.OriginalPurchId).Visible(false); columns.Bound(c => c.InventDimId).Visible(false); columns.Bound(c => c.InventQuantity).Visible(false); columns.Bound(c => c.LineAmountTax).Visible(false); columns.Bound(c => c.LineHeader).Visible(false); columns.Bound(c => c.RecVersion).Visible(false); columns.Bound(c => c.RecId).Visible(false); columns.Bound(c => c.Dimension4).Visible(false); columns.Bound(c => c.Source).Visible(false); columns.Bound(c => c.ApprovalUserId).Visible(false); columns.Bound(c => c.ApprovalDate).Visible(false); columns.Bound(c => c.ApprovalStatus).EditorTemplateName("ApprovalStatusEditor"); //columns.Command(command => { command.Edit(); }).Width(180); }) .ToolBar(toolbar => { toolbar.Excel(); toolbar.Save(); }) .Editable(editable => editable.Mode(GridEditMode.InCell)) .Pageable() .Navigatable() .Filterable() .Groupable() .DataSource(dataSource => dataSource .Ajax() .Model(model => { model.Id(p => p.CompanyId); model.Field(c => c.PurchId).Editable(false); model.Field(c => c.LineNum).Editable(false); model.Field(c => c.ItemId).Editable(false); model.Field(c => c.ExternalItemId).Editable(false); model.Field(c => c.Name).Editable(false); model.Field(c => c.CurrencyCode).Editable(false); model.Field(c => c.PriceUnit).Editable(false); model.Field(c => c.Quantity).Editable(false); model.Field(c => c.PurchUnit).Editable(false); model.Field(c => c.PurchasePrice).Editable(false); model.Field(c => c.DeliveryDate).Editable(false); }) .Read(read => read.Action("PurchaseJournalTransactions_Read", "Approval")) .Update(update => update.Action("PurchaseJournalTransactions_Update", "Approval")) ) ) <br /></div>
And here is the Controller:
using Microsoft.AspNet.Identity;using System;using System.Collections.Generic;using System.Data;using System.Data.Entity;using System.Linq;using System.Net;using System.Web;using System.Web.Mvc;using Kendo.Mvc.Extensions;using Kendo.Mvc.UI;using Portal.Model.DAX;namespace Portal.Views{ [Authorize(Roles="Vendor")] public class ApprovalController : Controller { private DAXContext db = new DAXContext(); public ActionResult Index() { return View(); } public ActionResult PurchaseJournalTransactions_Read([DataSourceRequest]DataSourceRequest request) { DataSourceResult result; IQueryable<PurchaseJournalTransaction> purchasejournaltransactions; string UserId = User.Identity.GetUserId(); //"ffd508d2-10e1-4b34-b1e1-f35862d90b70"; try { purchasejournaltransactions = from userVendor in db.UserVendors join vendor in db.Vendors on new { userVendor.CompanyId, userVendor.VendId } equals new { vendor.CompanyId, vendor.VendId } join journal in db.PurchaseJournals on new { p1 = (string)vendor.CompanyId, p2 = (string)vendor.VendId } equals new { p1 = (string)journal.CompanyId, p2 = (string)journal.OrderAccount } join tran in db.PurchaseJournalTransactions on new { p1 = (string)journal.CompanyId, p2 = (DateTime)journal.PurchaseOrderDate, p3 = (string)journal.PurchaseOrderId, p4 = (string)journal.PurchId } equals new { p1 = (string)tran.CompanyId, p2 = (DateTime)tran.PurchaseOrderDate, p3 = (string)tran.PurchaseOrderId, p4 = (string)tran.PurchId } where userVendor.UserId == UserId && tran.PurchaseLine.RemainPurchPhysical != 0 && tran.PurchaseLine.Purchase.PurchaseTypeId == 3 select tran; result = purchasejournaltransactions.ToDataSourceResult(request, purchaseJournalTransaction => new { CompanyId = purchaseJournalTransaction.CompanyId, PurchaseOrderDate = purchaseJournalTransaction.PurchaseOrderDate, PurchaseOrderId = purchaseJournalTransaction.PurchaseOrderId, InventTransId = purchaseJournalTransaction.InventTransId, PurchId = purchaseJournalTransaction.PurchId, LineNum = purchaseJournalTransaction.LineNum, ExternalItemId = purchaseJournalTransaction.ExternalItemId, Item = purchaseJournalTransaction.Item, ItemId = purchaseJournalTransaction.ItemId, Name = purchaseJournalTransaction.Name, CurrencyCode = purchaseJournalTransaction.CurrencyCode, Quantity = purchaseJournalTransaction.Quantity, LineAmount = purchaseJournalTransaction.LineAmount, ApprovalDate = purchaseJournalTransaction.ApprovalDate, ApprovalStatus = purchaseJournalTransaction.ApprovalStatus, PurchUnit = purchaseJournalTransaction.PurchUnit, PurchasePrice = purchaseJournalTransaction.PurchasePrice, PriceUnit = purchaseJournalTransaction.PriceUnit, PurchaseMarkup = purchaseJournalTransaction.PurchaseMarkup, DiscountPercentage = purchaseJournalTransaction.DiscountPercentage, DiscountAmount = purchaseJournalTransaction.DiscountAmount, Dimension1 = purchaseJournalTransaction.Dimension1, Dimension2 = purchaseJournalTransaction.Dimension2, Dimension3 = purchaseJournalTransaction.Dimension3, TaxAmount = purchaseJournalTransaction.TaxAmount, TaxWriteCode = purchaseJournalTransaction.TaxWriteCode, MultiLineDiscount = purchaseJournalTransaction.MultiLineDiscount, MultiLinePercent = purchaseJournalTransaction.MultiLinePercent, LineDiscount = purchaseJournalTransaction.LineDiscount, LinePercent = purchaseJournalTransaction.LinePercent, TaxGroup = purchaseJournalTransaction.TaxGroup, TaxItemGroup = purchaseJournalTransaction.TaxItemGroup, OriginalPurchId = purchaseJournalTransaction.OriginalPurchId, DeliveryDate = purchaseJournalTransaction.DeliveryDate, InventDimId = purchaseJournalTransaction.InventDimId, InventQuantity = purchaseJournalTransaction.InventQuantity, LineAmountTax = purchaseJournalTransaction.LineAmountTax, LineHeader = purchaseJournalTransaction.LineHeader, RecVersion = purchaseJournalTransaction.RecVersion, RecId = purchaseJournalTransaction.RecId, Dimension4 = purchaseJournalTransaction.Dimension4, Source = purchaseJournalTransaction.Source, ApprovalUserId = purchaseJournalTransaction.ApprovalUserId, ApprovalReasonId = purchaseJournalTransaction.ApprovalReasonId, }); return Json(result); } catch (Exception ex) { throw new HttpException(ex.InnerException.ToString()); } } [AcceptVerbs(HttpVerbs.Post)] public ActionResult PurchaseJournalTransactions_Update([DataSourceRequest]DataSourceRequest request, PurchaseJournalTransaction purchaseJournalTransaction) { if (ModelState.IsValid) { var entity = new PurchaseJournalTransaction(); entity = db.PurchaseJournalTransactions.FirstOrDefault(t => t.PurchaseOrderId == purchaseJournalTransaction.PurchaseOrderId && t.PurchaseOrderDate == purchaseJournalTransaction.PurchaseOrderDate && t.PurchId == purchaseJournalTransaction.PurchId && t.InventTransId == purchaseJournalTransaction.InventTransId && t.CompanyId == purchaseJournalTransaction.CompanyId ); //entity.CompanyId = purchaseJournalTransaction.CompanyId; //entity.PurchaseOrderId = purchaseJournalTransaction.PurchaseOrderId; //entity.PurchaseOrderDate = purchaseJournalTransaction.PurchaseOrderDate; //entity.PurchId = purchaseJournalTransaction.PurchId; //entity.InventTransId = purchaseJournalTransaction.InventTransId; //entity.LineNum = purchaseJournalTransaction.LineNum; //entity.ItemId = purchaseJournalTransaction.ItemId; //entity.ExternalItemId = purchaseJournalTransaction.ExternalItemId; //entity.Name = purchaseJournalTransaction.Name; //entity.CurrencyCode = purchaseJournalTransaction.CurrencyCode; //entity.Quantity = purchaseJournalTransaction.Quantity; //entity.PurchUnit = purchaseJournalTransaction.PurchUnit; //entity.PurchaseMarkup = purchaseJournalTransaction.PurchaseMarkup; //entity.PurchasePrice = purchaseJournalTransaction.PurchasePrice; //entity.DiscountPercentage = purchaseJournalTransaction.DiscountPercentage; //entity.DiscountAmount = purchaseJournalTransaction.DiscountAmount; //entity.LineAmount = purchaseJournalTransaction.LineAmount; //entity.Dimension1 = purchaseJournalTransaction.Dimension1; //entity.Dimension2 = purchaseJournalTransaction.Dimension2; //entity.Dimension3 = purchaseJournalTransaction.Dimension3; //entity.TaxAmount = purchaseJournalTransaction.TaxAmount; //entity.TaxWriteCode = purchaseJournalTransaction.TaxWriteCode; //entity.MultiLineDiscount = purchaseJournalTransaction.MultiLineDiscount; //entity.MultiLinePercent = purchaseJournalTransaction.MultiLinePercent; //entity.LineDiscount = purchaseJournalTransaction.LineDiscount; //entity.LinePercent = purchaseJournalTransaction.LinePercent; //entity.TaxGroup = purchaseJournalTransaction.TaxGroup; //entity.TaxItemGroup = purchaseJournalTransaction.TaxItemGroup; //entity.OriginalPurchId = purchaseJournalTransaction.OriginalPurchId; //entity.DeliveryDate = purchaseJournalTransaction.DeliveryDate; //entity.InventDimId = purchaseJournalTransaction.InventDimId; //entity.InventQuantity = purchaseJournalTransaction.InventQuantity; //entity.LineAmountTax = purchaseJournalTransaction.LineAmountTax; //entity.LineHeader = purchaseJournalTransaction.LineHeader; //entity.RecVersion = purchaseJournalTransaction.RecVersion; //entity.RecId = purchaseJournalTransaction.RecId; //entity.Dimension4 = purchaseJournalTransaction.Dimension4; if ( entity.ApprovalStatus != purchaseJournalTransaction.ApprovalStatus) { entity.ApprovalUserId = User.Identity.GetUserId(); entity.ApprovalDate = DateTime.Now; entity.ApprovalStatus = purchaseJournalTransaction.ApprovalStatus; entity.Source = ApprovalSource.Web; //entity.ApprovalReasonId = purchaseJournalTransaction.ApprovalReasonId; }; //db.PurchaseJournalTransactions.Attach(entity); db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); } else { } return Json(new[] { purchaseJournalTransaction }.ToDataSourceResult(request, ModelState)); } [HttpPost] public ActionResult Excel_Export_Save(string contentType, string base64, string fileName) { var fileContents = Convert.FromBase64String(base64); return File(fileContents, contentType, fileName); } protected override void Dispose(bool disposing) { db.Dispose(); base.Dispose(disposing); } }}
Here's what I'm doing:
// client side:
//I get a grid datasource filter
var fs = grid.dataSource.Filter()
// I then stringify it and pass it over to the server via an ajax call
// server side, I get the full filter string
// now i do this:
DataSourceRequest dsr = new DataSourceRequest();
Question: How do I take that filter string and recreate the full datasource Filters ?
p.s. I have to do it this way - I cannot have a DataSourceRequest in the endpoint parameters passed in.
I'm sharing a datasource between a grid and listview. Everything works great - except when the user groups in the grid - the listview is unable to deal with a datasource having groups. Sorting and filtering works great.
Would it be possible in the future to consider adding grouping to listviews where the listview code would use the same datasource functionality as found in the grid grouping functionality?
Thanks,
Rene.
Hi all,
I've seen all of the 4 episodes of the Getting Started with the Kendo UI for ASP.Net MVC, however I can't seem to figure out how to set up a DataSource with a Generic ObjectList.
This is the piece of code I currently have:
public JsonResult Get([DataSourceRequest] DataSourceRequest request){ Runner runner = new Runner(); Task<List<CustomOrder>> customOrderResult = Task.Run(async () => await runner.GetCustomOrders().ConfigureAwait(false)); Task.WhenAll(customOrderResult); List<CustomOrder> customOrders = customOrderResult.Result;}​I know it ain't perfect. Going to refactor it as soon as I got it working properly.
Thanks in advance for all your help.
Hello All,
i have attach a file to this thread which is based on the VSflexgrid control in asp technology.
the same functionality i want to achieve using telerik treelist control with asp.net mvc.
In the attach file there are two horizontal parts.
the above part display the treeview in left side and the associated grid that to with editable cell like excel into it towards the right side.
if we write anything on the grid cell say a number i type there the below part where there are also a grid with dynamic row and column description
gets added the value into it.
Kindly let me know if this functionality is achievable .
Please go through the attach file screenshot and kindly let me know.