Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/394.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何删除剑道网格中的行_Javascript_Asp.net Mvc 3_Linq To Sql_Kendo Grid - Fatal编程技术网

Javascript 如何删除剑道网格中的行

Javascript 如何删除剑道网格中的行,javascript,asp.net-mvc-3,linq-to-sql,kendo-grid,Javascript,Asp.net Mvc 3,Linq To Sql,Kendo Grid,有人能在我的项目中帮我解决这个问题吗。。 我的工人有不同的登录名和相同的角色。我有一个客户页面,员工可以申请不同班次的公司职位(网格)(公司职位内的另一个网格)。当工人申请该轮班时,该行将在网格中消失 我的问题是。。我想在其他工作人员登录时再次显示该行 我该怎么做。。我只在一个工人身上做了这件事 这是我所拥有的 控制器: //to load the data of the grid public JsonResult LoadCustomerPositionShiftWorkerList(int

有人能在我的项目中帮我解决这个问题吗。。 我的工人有不同的登录名和相同的角色。我有一个客户页面,员工可以申请不同班次的公司职位(网格)(公司职位内的另一个网格)。当工人申请该轮班时,该行将在网格中消失

我的问题是。。我想在其他工作人员登录时再次显示该行

我该怎么做。。我只在一个工人身上做了这件事

这是我所拥有的

控制器:

//to load the data of the grid
public JsonResult LoadCustomerPositionShiftWorkerList(int? clientCusPosId, int? clientId)
        {
            List<userWorkerCompare> workerDetails = new List<userWorkerCompare>();
            GlobalVariables.SiteMapFile = "ClientSiteMapProvider";
            MembershipUser membershipUser = Membership.GetUser();
            string userId = membershipUser.ProviderUserKey.ToString();


            var workerIdList = new List<Int32>();
            var customerPositionShiftList = new List<Client_Customer_Position_Shift>();
            List<ClientCustomerPositionShiftInfo> clientCustomerPositionShiftList = new List<ClientCustomerPositionShiftInfo>();
            var filterList = (from a in db.Worker_Customer_Apply_Shift
                              where a.LogicalDelete == false && a.Client_Customer_PositionID == clientCusPosId
                              select a).ToList();
            //this is to get workerId
            if (Roles.IsUserInRole("Worker"))
            {
                var listWorker = (from a in db.Workers
                                  where a.LogicalDelete == false
                                  select new
                                  {
                                      a.ID,
                                      a.userId,
                                      a.FirstName,
                                      a.LastName,
                                      a.MiddleName,
                                      a.BirthDate,
                                      a.Gender_LookID,
                                      a.LogicalDelete

                                  }).ToList();

                if (listWorker.Count() > 0)
                {
                    foreach (var row in listWorker)
                    {

                        var cli = new userWorkerCompare
                        {
                            ID = row.ID,
                            FirstName = row.FirstName,
                            MiddleName = row.MiddleName,
                            LastName = row.LastName,
                            LogicalDelete = row.LogicalDelete,
                            userId = row.userId.ToString()
                        };
                        workerDetails.Add(cli);
                    }

                    var workerProfile = (from a in workerDetails
                                         join b in db.Workers
                                         on a.ID equals b.ID
                                         where a.LogicalDelete == false && a.userId == userId
                                         select b).SingleOrDefault();
                    ViewBag.WorkerProfile = workerProfile;

                    var workerAvail = (from a in db.Worker_Availability
                                       where a.LogicalDelete == false
                                       && a.Worker_ID == workerProfile.ID
                                       select a).ToList();
                    ViewBag.WorkerAvail = workerAvail;

                    var workerId = (from a in workerDetails
                                    where a.LogicalDelete == false && a.userId == userId
                                    select a.ID).SingleOrDefault();
                    ViewBag.WorkerId = workerId;
                    //this is to compare customer position shift from worker availability
                    if (clientCusPosId.HasValue)
                    {
                        customerPositionShiftList = (from a in db.Client_Customer_Position_Shift
                                                     where a.LogicalDelete == false && a.Client_Customer_PositionID == clientCusPosId
                                                     select a).ToList();
                        foreach (var row in customerPositionShiftList)
                        {


                            var workerList = (from a in db.Worker_Availability
                                              where a.LogicalDelete == false && a.Worker_ID == workerProfile.ID
                                              select a).ToList();
                            foreach (var Availability in workerList)
                            {

                                if (Availability.AvailableDay_LookID == row.Day_LookID || Availability.AvailableDay_LookID == 76 || row.Day_LookID == 76)
                                {

                                    if (((Availability.StartTime == "Anytime" && Availability.EndTime == "Anytime") || (row.StartTime == "Anytime" && row.EndTime == "Anytime")) ||
                                         (row.StartTime == "Anytime" || row.EndTime == "Anytime") || (Availability.StartTime == "Anytime" || Availability.EndTime == "Anytime"))
                                    {
                                        workerIdList.Add(row.ID);
                                    }
                                    else
                                    {
                                        DateTime availStartTime = Convert.ToDateTime(Availability.StartTime);
                                        DateTime posStartTime = Convert.ToDateTime(row.StartTime);
                                        DateTime availEndTime = Convert.ToDateTime(Availability.EndTime);
                                        DateTime posEndTime = Convert.ToDateTime(row.EndTime);


                                        if ((Availability.StartTime == row.StartTime &&
                                            Availability.EndTime == row.EndTime) || (Availability.StartTime == row.StartTime ||
                                            Availability.EndTime == row.EndTime) || (availStartTime < posStartTime && availEndTime > posEndTime))
                                        {
                                            workerIdList.Add(row.ID);
                                        }
                                    }

                                }
                            }
                        }
                    }

                    //to show compared list

                        var toBeList = (from a in customerPositionShiftList
                                        where a.LogicalDelete == false
                                        select a).ToList();
                    //after applying this one triggers to hide the row 
                        var setToList =
                           toBeList.Select(x => x.ID).Except(filterList.Select(y => y.clientCusPosShiftId)).ToList();

                        var cusWorkList = (from a in db.Client_Customer_Position_Shift
                                           where a.LogicalDelete == false
                                         && workerIdList.Contains(a.ID)
                                         && setToList.Contains(a.ID)
                                           select new
                                           {
                                               a.ID,
                                               a.Client_CustomerID,
                                               a.Client_Customer_PositionID,
                                               a.Day_LookID,
                                               a.EndTime,
                                               a.StartTime,
                                               a.LogicalDelete


                                           }).ToList();

                        if (cusWorkList.Count() > 0)
                        {
                            foreach (var row in cusWorkList)
                            {
                                ClientCustomerPositionShiftInfo ccpsi = new ClientCustomerPositionShiftInfo
                                {

                                    ID = row.ID,
                                    ClientID = clientId.HasValue ? clientId.Value : 0,
                                    Client_Customer_PositionID = row.Client_Customer_PositionID,
                                    Client_CustomerID = row.Client_CustomerID,
                                    Day = GetLookupDisplayValById(row.Day_LookID),
                                    StartTime = row.StartTime != "Anytime" ? Convert.ToDateTime(row.StartTime).ToString("hh:mm tt") : row.StartTime.Trim(),
                                    EndTime = row.EndTime != "Anytime" ? Convert.ToDateTime(row.EndTime).ToString("hh:mm tt") : row.EndTime.Trim(),
                                    DayID = (row.Day_LookID)

                                };
                                clientCustomerPositionShiftList.Add(ccpsi);
                            }

                        }

                }
            }

            return Json(clientCustomerPositionShiftList.ToList().OrderBy(p => p.DayID), JsonRequestBehavior.AllowGet);
        }
//加载网格的数据
公共JsonResult LoadCustomerPositionShiftWorkerList(int?clientCusPosId,int?clientId)
{
List workerDetails=新列表();
GlobalVariables.SiteMapFile=“ClientSiteMapProvider”;
MembershipUser MembershipUser=Membership.GetUser();
字符串userId=membershipUser.ProviderUserKey.ToString();
var workerIdList=新列表();
var customerPositionShiftList=新列表();
List clientCustomerPositionShiftList=新列表();
var filterList=(来自db.Worker\u Customer\u Apply\u Shift中的
其中a.LogicalDelete==false&&a.Client\u Customer\u PositionID==clientCusPosId
选择一个.ToList();
//这是为了得到workerId
if(Roles.IsUserInRole(“Worker”))
{
var listWorker=(来自db.Workers中的
其中a.LogicalDelete==false
选择新的
{
a、 身份证,
a、 用户ID,
a、 名字,
a、 姓,
a、 MiddleName,
a、 生日,
a、 性别与外貌,
a、 逻辑电极
}).ToList();
如果(listWorker.Count()>0)
{
foreach(listWorker中的var行)
{
var cli=新用户工作比较
{
ID=行。ID,
FirstName=row.FirstName,
MiddleName=row.MiddleName,
LastName=row.LastName,
LogicalDelete=行。LogicalDelete,
userId=row.userId.ToString()
};
workerDetails.Add(cli);
}
var workerProfile=(来自workerDetails中的
加入db.Workers中的b
a.ID等于b.ID
其中a.LogicalDelete==false&&a.userId==userId
选择b).SingleOrDefault();
ViewBag.WorkerProfile=WorkerProfile;
var workerAvail=(来自db.Worker\u可用性中的
其中a.LogicalDelete==false
&&a.Worker\u ID==workerProfile.ID
选择一个.ToList();
ViewBag.WorkerAvail=WorkerAvail;
var workerId=(来自workerDetails中的
其中a.LogicalDelete==false&&a.userId==userId
选择a.ID).SingleOrDefault();
ViewBag.WorkerId=WorkerId;
//这是为了比较客户职位变动与工人可用性
if(clientCusPosId.HasValue)
{
customerPositionShiftList=(来自db.Client\u Customer\u Position\u Shift中的
其中a.LogicalDelete==false&&a.Client\u Customer\u PositionID==clientCusPosId
选择一个.ToList();
foreach(CustomerPositionShift列表中的var行)
{
var workerList=(来自db.Worker\u可用性中的
其中a.LogicalDelete==false&&a.Worker\u ID==workerProfile.ID
选择一个.ToList();
foreach(workerList中的var可用性)
{
如果(Availability.AvailableDay_LookID==row.Day_LookID | | | Availability.AvailableDay_LookID==76 | | row.Day_LookID==76)
{
if((Availability.StartTime==“Anytime”&&Availability.EndTime==“Anytime”)| |(row.StartTime==“Anytime”&&row.EndTime==“Anytime”))||
(row.StartTime==“Anytime”| | row.EndTime==“Anytime”)| |(Availability.StartTime==“Anytime”| | Availability.EndTime==“Anytime”))
{
workerIdList.Add(row.ID);
}
其他的
{
DateTime availstartime=Convert.ToDateTime(Availability.StartTime);
DateTime posStartTime=Convert.ToDateTime(row.StartTime);
DateTime availEndTime=Convert.ToDateTime(Availability.EndTime);
DateTime posEndTime=Convert.ToDateTime(row.EndTime);
如果((Availability.StartTime==行.StartTime)&&
Availability.EndTime==行.EndTi
<script type="text/javascript">
        $(document).ready(function () {
 var comparegrid = $("#positionShiftWorkerComparedGrid").kendoGrid({
                scrollable: false,
                sortable: true,
                pageable: true,
                dataSource: {
                    transport: {
                        read: {
                            url: '/Customer/LoadCustomerPositionShiftWorkerList?clientCusId=' + clientCusId + '&clientId=' + clientId + '&clientCusPosId=' + clientCusPosId,
                            dataType: "json",
                            type: "POST"
                        }
                    },
                    pageSize: 10
                },
                rowTemplate: kendo.template($("#positionShiftWorkerComparedTemplate").html().replace('k-alt', '')),
                altRowTemplate: kendo.template($("#positionShiftWorkerComparedTemplate").html())
            });


});
</script>