Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/418.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 telerik kendoui电网未分配额外数据的参数(电网按需负荷)_Javascript_Asp.net Mvc 4_Razor_Kendo Grid - Fatal编程技术网

Javascript telerik kendoui电网未分配额外数据的参数(电网按需负荷)

Javascript telerik kendoui电网未分配额外数据的参数(电网按需负荷),javascript,asp.net-mvc-4,razor,kendo-grid,Javascript,Asp.net Mvc 4,Razor,Kendo Grid,目前,我在加载网格时遇到了一个问题,这个问题取决于传递给网格的参数。 我正在开发一个搜索页面,其中有一个文本框和按钮。 我将在按钮的点击事件上显示网格,并将文本框输入文本作为参数 我的文本框和按钮: <divid="SearchSection"> <input type="text"id="txtSearch"class="k-textbox"/> <buttonid="btnSearch" class="k-button"style="wi

目前,我在加载网格时遇到了一个问题,这个问题取决于传递给网格的参数。 我正在开发一个搜索页面,其中有一个文本框和按钮。 我将在按钮的点击事件上显示网格,并将文本框输入文本作为参数

我的文本框和按钮:

 <divid="SearchSection">
    <input  type="text"id="txtSearch"class="k-textbox"/> 
    <buttonid="btnSearch"  class="k-button"style="width:150px">Search</button>
</div>
调用单击事件并捕获文本框输入的脚本:

   <script>
       $(document).ready(function () {
         $("#ADUserSection").fadeIn();
       $("#btnSearch").click(function () {
              debugger;
         var text =AdditionalData().toString();
          var grid = $("#kADUser").data("kendoGrid");
       grid.dataSource.read({searchText:text});
         });
          });
        </script>
型号:

         public class ADUser
          {
          public string UserLoginName { get; set; }
                public string UserDisplayName { get; set; }
            }
           public List<ADUser> GetUserFromAD(string name) //Get Network Users (AD)
                {
                  var searchUser = newList<ADUser>();
                 var domainContext = newPrincipalContext(ContextType.Domain);
                    var groupPrincipal = GroupPrincipal.FindByIdentity(domainContext,           IdentityType.SamAccountName, "Domain Users");
                  UserPrincipal user = newUserPrincipal(domainContext);
                 if (!String.IsNullOrEmpty(name))
                    {
                      user.Enabled = true;
                       user.Name = name + "*";
                          PrincipalSearcher pS = newPrincipalSearcher();
                           pS.QueryFilter = user;
                            PrincipalSearchResult<Principal> results = pS.FindAll();

                            foreach (var item in results)
                             {
                                  var users = new FMSystemWeb.Models.ADUser();
                                   users.UserLoginName = item.SamAccountName;
                                   users.UserDisplayName = item.DisplayName;
                                   searchUser.Add(users);
                              }
                         }
                       return searchUser;
                       }
因此,我的控制器方法在参数中始终为null,网格不显示任何结果。

按需事件

  // Bouquet combo change event
    $('#BooketID').live('change', function () {
        FillChannelGridByBouquetID();
    });
设置网格负荷的参数

/* Load kendo grid by bouquetID*/
    function FillChannelGridByBouquetID() {
        var a = {};
        a.BooketID = $("#BooketID option:selected").val();
        var mAGrid = $('#CustomerPackageChannelKendoGrid').data('kendoGrid');
        mAGrid.dataSource.read(a);
        }
网格

控制器

public JsonResult ChannelReadByBooketID(CustomerPackageViewModel booketModel)
        {
            var models = GetAllChannelByBooketID(booketModel.BooketID.ToString());
            return Json(models, JsonRequestBehavior.AllowGet);
        }      

 private List<ChannelViewModel> GetAllChannelByBooketID(string pBooketID)
        {
            Guid gBooketID;

            if (!Guid.TryParse(pBooketID, out gBooketID))
            {
                return null;
            }

            var ViewModels = _bCService.BillingUnit.ChannelRepository.Get(t => t.BooketID == gBooketID).ToList().Select(
                 md => new ChannelViewModel
                 {
                     ChannelID = md.ChannelID,
                     ChannelName = md.ChannelName,
                     BooketID = md.BooketID,
                     BooketName = md.DJBL_tblBooket.BooketName

                 }).OrderBy(o => o.BooketName);

            return ViewModels.ToList();
        }

为什么要从AdditionalData返回对象?调用代码似乎只需要字符串;您应该首先验证$txtSearch.val是否为您提供了正确的值,例如,将其记录到我通过放置调试器脚本验证的ConsoleEyes,并将警报置于$txtSearch.val上。我甚至试过使用$txtSearch.val.toString。我可以正确地捕获输入文本,但返回时没有分配该文本。我没有得到关于我的问题的任何正确方向,因此从该网站向telerik提出了一个问题。telerik说这是一个已知的问题,它已经在他们的服务包sp2中得到解决,我必须将我的项目升级到新版本,它成功了。但我真的很难做到。因此,如果有人有相同的问题,请将您的项目升级到新版本。这对我来说非常有效,使用您的控制器方法示例,因为默认控制器方法不允许我传入自己的自定义“过滤器”。默认控制器是ActionResult,而不是JsonResult。
             public class ViewModelManageUsers
              {
                public List<UserRoleList> assignedUserRole { get; set; }
                public List<ADUser> searchedADUser { get; set; }
                public List<AvailableRoles> availableRoles { get; set; }
              }
 function AdditionalData() {
      never gets the data assigned to my parameter 
    searchText
  // Bouquet combo change event
    $('#BooketID').live('change', function () {
        FillChannelGridByBouquetID();
    });
/* Load kendo grid by bouquetID*/
    function FillChannelGridByBouquetID() {
        var a = {};
        a.BooketID = $("#BooketID option:selected").val();
        var mAGrid = $('#CustomerPackageChannelKendoGrid').data('kendoGrid');
        mAGrid.dataSource.read(a);
        }
$("#CustomerPackageChannelKendoGrid").kendoGrid({
        dataSource:
        {
            transport:
            {
                read: "ChannelReadByBooketID",
            },
            schema:
            {
                model:
                {
                    fields:
                    {
                        SelectColumn: {type: "boolean"},
                        ChannelID: { type: "string" },
                        BooketName: { type: "string" },
                        ChannelName: { type: "string" },
                    }
                }
            },
            pageSize: 20,
            serverPaging: false,
            serverFiltering: false,
            serverSorting: false
        },
        height: 200,
        filterable: true,
        groupable: true,
        sortable: true,
        resizable: true,                                                                
        pageable:
        {
            refresh: false,
            pageSizes: [20, 40, 60, 80, 100]
        },
        columns:
        [
            {
                field: "SelectColumn", title: " ", width: "5%",
                template: "<input type='checkbox' #= SelectColumn ? checked='checked':'' # class='chkbx' />"
            },

            { field: "ChannelID", title: "ChannelID", hidden: true, filterable: false, sortable: false },
            { field: "BooketName", title: "Bouquet Name", width: "30%" },
            { field: "ChannelName", title: "Channel Name", width: "30%" },
        ]
    });
public JsonResult ChannelReadByBooketID(CustomerPackageViewModel booketModel)
        {
            var models = GetAllChannelByBooketID(booketModel.BooketID.ToString());
            return Json(models, JsonRequestBehavior.AllowGet);
        }      

 private List<ChannelViewModel> GetAllChannelByBooketID(string pBooketID)
        {
            Guid gBooketID;

            if (!Guid.TryParse(pBooketID, out gBooketID))
            {
                return null;
            }

            var ViewModels = _bCService.BillingUnit.ChannelRepository.Get(t => t.BooketID == gBooketID).ToList().Select(
                 md => new ChannelViewModel
                 {
                     ChannelID = md.ChannelID,
                     ChannelName = md.ChannelName,
                     BooketID = md.BooketID,
                     BooketName = md.DJBL_tblBooket.BooketName

                 }).OrderBy(o => o.BooketName);

            return ViewModels.ToList();
        }