Grid Doesn't Populate after publishing

3 posts, 0 answers
  1. technotes
    technotes avatar
    9 posts
    Member since:
    Jan 2013

    Posted 16 Sep 2015 Link to this post

    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);
            }
        }
    }

     

     

     

  2. technotes
    technotes avatar
    9 posts
    Member since:
    Jan 2013

    Posted 16 Sep 2015 Link to this post

    So I figured out what caused it, but not sure why....

    On of the properties I was mapping was a complex type of (InventItem) item.  When I removed that it started working...  Still don't follow why that is.

  3. UI for ASP.NET MVC is VS 2017 Ready
  4. T. Tsonev
    Admin
    T. Tsonev avatar
    2770 posts

    Posted 21 Sep 2015 Link to this post

    Hi,

    Please accept my apologies for the delayed response.

    I'm glad to hear you've got this working.
    Are you sure there are no errors visible in the browser console?

    Regards,
    T. Tsonev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top