This is a migrated thread and some comments may be shown as answers.

Passing id of detail row to sub popup.

1 Answer 17 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 09 Mar 2019, 12:59 PM

Ok So I have made some modifications based on teleriks suggestion but now the grid is not readling the lines

 

[AcceptVerbs("Get")]
public ActionResult ActivityLines_Read([DataSourceRequest]DataSourceRequest request ,int? activityID)
{
 
 
    int? _activityId = activityID;
    var result = GetAllActivityLines(activityID);
 
    var dsResult = result.ToDataSourceResult(request);
    return Json(dsResult);
 
}

 

 

The goal I need to achieve is to pass the header id into the lines  and then on my view details button pass the id to the popup so that it is their for saving saving from the main window is not the modal i want to follow which was a suggestion in support ticket.

 

                <div class="form-group row">
 
                    <div class="col-sm-12">
 
                        @(Html.Kendo().Grid<FuelActivityTrackerDal.Models.ActivityLines>
().Name("activityLines")
                        .AutoBind(false)
                        .Events(e => e.Edit("onEdit"))
                        .Columns(columns =>
                        {
                            columns.Bound(p => p.Description).Filterable(false);
                            columns.Bound(p => p.StartTime).Filterable(false);
                            columns.Bound(p => p.EndTime).Filterable(false);
                            columns.Bound(p => p.Status);
                            columns.Command(command => command.Custom("ViewDetails").Click("showDetails"));
 
                        })
                        .DataSource(dataSource => dataSource
                        .Ajax()
                        .Events(events => events.Error("error_handler"))
                        .Model(model => model.Id(p => p.ActivityLineId))
                        .Read(read => read.Action("ActivityLines_Read", "Activity"))
                       .Update(update => update.Action("ActivityLines_Update", "Activity").Type(HttpVerbs.Post)))
 
    )
</div>
                </div>
 
                <div class="form-group row">
                    <div class="col-sm-6">
 
                    </div>
                </div>
 
 
                <button type="button" class="btn btn-primary px-4 float-right">Add Work Item</button>
                <button type="button" class="btn btn-primary px-4 float-right">Put Case & Client On Hold</button>
                <button type="button" class="btn btn-primary px-4">Cancel</button>
            </form>
        </div>
    </div>
    @(Html.Kendo().Window().Name("Details")
                    .Title("Activity Details")
                    .Visible(false)
                    .Modal(true)
                    .Draggable(true)
                    .Width(400)
    )
    <script type="text/x-kendo-template" id="template">
        <form method="post" action="@Url.Action("ActivityLines_Update", "Activity")">
 
            <div id="details-container">
 
                ActivitiyHeadId
                <div class="form-group row">
                    <div class="col-sm-9">
                        <label for="inputFirstname">Activty Name</label>
                        <input type="text" class="form-control" id="inputFirstname" placeholder="Activity name">
                    </div>
                </div>
                <div class="form-group row">
                    <div class="col-md-10">
                        <label for="inputLastname" class="form-control">Description</label>
                  
                    </div>
                </div>
                <div class="form-group row">
                    <div class="col-md-6">
                        <label for="inputLastname" class="form-control">Start Time</label>
 
 
                    </div>
                    <div class="col-md-6">
                        <label for="inputLastname" class="form-control">End Time </label>
 
 
                    </div>
                </div>
 
            </div>
            <input type="submit" class="btn btn-file px-4" value="Save Work Item" />
 
 
            <button type="button" class="btn btn-primary px-4">Cancel</button>
 
        </form>
    </script>

 

My Entire activity controller.

 

public class ActivityController : Controller
    {
        public int ActivityLineId { get; set; }
        private readonly IActivityHeaderRepository _activityRepo;
        public ActivityController(IActivityHeaderRepository activityRepo)
        {
 
 
            _activityRepo = activityRepo;
 
        }
        [AcceptVerbs("Post")]
        public bool SaveWorkItem(ActivityLines activityLines)
        {
       
            return _activityRepo.UpdateActivityLines(activityLines);
 
 
        }
   
        [AcceptVerbs("Post")]
        public ActionResult EditingPopup_Update([DataSourceRequest] DataSourceRequest request, ActivityHeader activity)
        {
            if (activity != null)
            {
                UpdateActivity(activity);
            }
 
            return Json(new[] { activity }.ToDataSourceResult(request, ModelState));
        }
        [AcceptVerbs("Post")]
        public ActionResult ActivityLines_Update([DataSourceRequest] DataSourceRequest request, ActivityLines activityLines,int? activityID)
        {
 
            if (activityLines != null)
            {
                _activityRepo.UpdateActivityLines(activityLines);
            }
            return Json(new[] { activityLines }.ToDataSourceResult(request, ModelState));
 
 
 
        }
        [AcceptVerbs("Get")]
        public ActionResult ActivityLines_Read([DataSourceRequest]DataSourceRequest request ,int? activityID)
        {
 
 
            int? _activityId = activityID;
            var result = GetAllActivityLines(activityID);
 
            var dsResult = result.ToDataSourceResult(request);
            return Json(dsResult);
 
        }
 
 
 
        public ActionResult Activity_Read([DataSourceRequest]DataSourceRequest request)
        {
            var result = GetAllActivityHeader();
 
            var dsResult = result.ToDataSourceResult(request);
            return Json(dsResult);
        }
        public List<ActivityEditViewModal> GetAllActivityHeader()
        {
            return _activityRepo.GetAllActivites();
        }
        public List<ActivityLines> GetAllActivityLines(int? activityID)
        {
            return _activityRepo.GetActivityLines(activityID);
        }
 
 
        public bool UpdateActivityLines(ActivityLines activityLine)
        {
            return _activityRepo.UpdateActivityLines(activityLine);
        }
 
        public bool UpdateActivity(ActivityHeader activityHeader)
        {
            return _activityRepo.UpdateActivityHeader(activityHeader);
        }
 
        public ActionResult Index()
        {
            List<StaffMembers> _staffmembers = new List<StaffMembers>();
            _staffmembers = _activityRepo.GetAllStaffMembers();
            _staffmembers.Insert(0, new StaffMembers { DepartmentId = 0, StaffID = 0, FirstName = "Select" });
            ViewBag.ListOfStaff = _staffmembers;
 
            var _projectTypes = _activityRepo.GetStandardLookups(Constants.ProjectTypesLookupGroup);
            ViewBag.ProjectTypes = _projectTypes;
 
 
            var _projectStatusTypes = _activityRepo.GetStandardLookups(Constants.ProjectStatusLookupGroup);
            ViewBag.ProjectStatusTypes = _projectStatusTypes;
            SetupRadioButtons();
             var acitivityList = GetAllActivityHeader();
            return View(acitivityList);
 
        }
 
        public void SetupRadioButtons()
        {
            List<SelectListItem> items = new List<SelectListItem>();
 
            Dictionary<string, string> dictionary = new Dictionary<string, string>();
 
            dictionary.Add("Sop", "1");
            dictionary.Add("Remote", "2");
            dictionary.Add("OnSite", "3");
 
            foreach (KeyValuePair<string, string> pair in dictionary)
            {
                items.Add(new SelectListItem() { Text = pair.Key, Value = pair.Value, Selected = false });
            }
 
            ViewBag.Location = new SelectList(items, "Value", "Text");
        }
  
    }
}

 

 

My Model of detail and lines

 

public class ActivityHeader
{
    public int ActivityHeaderId { get; set; } //(int, null)
    public DateTime? ActivityDate { get; set; } //(date, null)
    public string Name { get; set; } //(nvarchar(350), null)
    public DateTime? ActivityEndDate { get; set; } //(datetime, null)
    public string ProblemDescription { get; set; }
    public string Description { get; set; } //(nvarchar(max), null)
 
    public int? ActivityLinesId { get; set; } //(int, null)
    public int? HoursLeftOnProject { get; set; } //(time(7), null)
    public int? Status { get; set; } //(nchar(10), null)
      public DateTime? CreatedDate { get; set; } //(date, null)
    public string CreatedBy { get; set; } //(nvarchar(50), null)
    public bool? isActive { get; set; } //(bit, null)
    public bool? isDeleted { get; set; } //(bit, null)
    public bool? isArchived { get; set; } //(bit, null)
    public int? SOP { get; set; } //(nvarchar(50), null)
    public int? OnSite { get; set; }
    public int? Remote { get; set; }
     
    public int? DepartmentId { get; set; } //(int, null)
    public string EmployeeName { get; set; } //(nvarchar(301), null)
    [ForeignKey("StaffId")]
    public int? StaffId { get; set; }
    public  virtual StaffMembers StaffMembers { get; set; }
 
    public ICollection<ActivityLines> ActivityLines { get; set; }
 
 
}

As you see above activity lines is a ICollection of activity header  All i want to be able to do is a simple crud on the lines within the popup.

public class ActivityLines
    {
        [Key]
        public int ActivityLineId { get; set; } //(int, not null)
        public int? ActivityHeaderId { get; set; } //(int, null)
        public string Description { get; set; } //(nvarchar(max), null)
        public string Notes { get; set; } //(nvarchar(max), null)
        public DateTime? StartTime { get; set; } //(time(7), null)
        public DateTime? EndTime { get; set; }
        public DateTime? StartDate { get; set; }
        public DateTime? EndDate { get; set; } //(time(7), null)
        public int? StaffMemeber { get; set; } //(int, null)
        public bool? isActive { get; set; } //(bit, null)
        public bool? isDeleted { get; set; } //(bit, null)
        public string CreatedBy { get; set; } //(nvarchar(50), null)
        public DateTime? CreatedDate { get; set; } //(date, null)
        public int? Status { get; set; } //(int, null)
      
    }

 

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 13 Mar 2019, 03:36 PM
Hello David,

I just replied in the support thread that you have about this problem. You can check my reply there. I am leaving the thread open in case anyone else wants to share a suggestion regarding your scenario, but I suggest we continue our discussion in the support ticket, so all information and instructions are available in one place.

Regards,
Tsvetina
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or