输入按钮不触发字符串参数的事件。 [英] Input button not firing event for string parameter.

查看:75
本文介绍了输入按钮不触发字符串参数的事件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将参数传递给Kendo grid.It确实传递参数,如果它的整数100并且工作正常,但如果它的ZZ001.can任何人帮忙都不会触发事件?

我的代码如下:

I am trying pass parameter to the Kendo grid.It does pass parameter if its integer "100" and works perfect,but doesn't fire event if its ZZ001.can anyone help?
My code is as below:

@(Html.Kendo().Grid<orderlineview>()
      .Name("OrderLineGrid")
      .Columns(columns =>
      {
          //columns.Bound(p => p.SerialNo);

          columns.Bound(p => p.StockCode).Title("Stock Code").Width(250);
          columns.Bound(p => p.OrderLineDescription).Title("Description");
          columns.Bound(p => p.Quantity).HtmlAttributes(new { style = "text-align:right" });
          columns.Bound(p => p.UnitPrice).Format("{0:c}").HtmlAttributes(new { style = "text-align:right" });
          columns.Bound(p => p.DiscountPercentage).Title("Disc %").Width(70).HtmlAttributes(new { style = "text-align:right" });
          columns.Bound(p => p.DiscountAmount).Title("Discount  ").Format("{0:c}").HtmlAttributes(new { style = "text-align:right" });
          columns.Bound(p => p.TaxRate).HtmlAttributes(new { style = "text-align:right" });
          columns.Bound(p => p.TaxAmount).Title("Tax Amount").Format("{0:c}").HtmlAttributes(new { style = "text-align:right" });
          columns.Bound(p => p.TotalPrice).Format("{0:c}").HtmlAttributes(new { style = "text-align:right" });



          columns.Command(command =>
          {
              command.Edit().UpdateText(" ").CancelText(" ");
              //command.Custom("").Text("History").Click("OpenItemhistoryPopup");
              //command.Custom("Delete").Click("deleteRow");
              command.Destroy();
          }).Width(170);

          columns.Bound("").ClientTemplate("<input type='button' onclick='OpenItemhistoryPopup(#=StockCode #)' value='History' ></input>");

      })
      .ToolBar(toolbar => toolbar.Create())


      .Editable(editable => editable.Mode(GridEditMode.InLine)
      //.CreateAt(GridInsertRowPosition.Bottom)
      )
      //.Pageable()
      //.Sortable()
      //.Scrollable()
      .HtmlAttributes(new { style = "height:430px; overflow-y:scroll" })
      .Events(ev=>ev.Edit("EditGrid")
          .Save("Rearrange")
      )
      .DataSource(dataSource => dataSource
          .Ajax()

          //.Sort(sort => sort.Add("SerialNo"))
          //.PageSize(20)
          //.Events(events => events.Error("error_handler"))
          .Events(e => e.RequestEnd("onRequestEnd"))
          //.Events(e=>e.Push("Rearrange"))
          .Model(model => model.Id(p => p.OrderLineId))
          .Create(update => update.Action("OrderLineCreate", "Order"))
          .Read(read => read.Action("GetAllOrderLines", "Order"))
          .Update(update => update.Action("OrderLineUpdate", "Order"))//.Data("additionalData")
          .Destroy(update => update.Action("OrderLineDelete", "Order"))
          .Events(events =>  events.Error("error_handler"))
      //.Events(events =>  events.Push("Rearrange"))



      ))





JavaScript如下:



JavaScript is as follows:

function OpenItemhistoryPopup(stockCode) {
        try {
          
            if (stockCode == null) {
                return;
            }
                
            //return;
            var url = '@ConfigurationManager.AppSettings["BaseUrl"]Order/ItemPriceHistory?stockCode=' + stockCode;
            $("#windowfritempricehistory").data("kendoWindow").open();
            $("#windowfritempricehistory").data("kendoWindow").refresh(url);
            $("#windowfritempricehistory").data("kendoWindow").center();      

        } catch (e) {
            alert(e);
        }
    }



C#代码


C# code

public ActionResult Itempricehistorydetails([DataSourceRequest] DataSourceRequest request, string searchvalue)
{
   // searchvalue = "100";
    return Json(Itempricehistorydetails(searchvalue).ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}

private IQueryable<Itempricehistory> Itempricehistorydetails(string stockcode)
{
    string city = (string)(Session["password"]);

    int intstockcode = Convert.ToInt32(stockcode);
    SessionContext sessionContext = CurrentSession;
    string myObUrl = sessionContext.Url;
    string myObUser = sessionContext.LogInUserName;
    string myObPassword = city;
    string custcode = sessionContext.CurrentCustomerId;
    string dtfrom = DateTime.Now.AddYears(-1).ToString("dd/MM/yyyy");
    string dateTo = DateTime.Now.ToString("dd/MM/yyyy");


    string url = ConfigurationManager.AppSettings["BaseServiceUrl"] + "Order/GetSalesHistoryByCustomerByInventoryId? &user=" + myObUser + "&password=" + myObPassword + "&customerId=" + custcode + "&itemCode=" + intstockcode + "&dateFrom=" + dtfrom + "&dateTo=" + dateTo;
    string jSon = CallApi(url);
    List<Itempricehistory> orders = new JavaScriptSerializer().Deserialize<List<Itempricehistory>>(jSon);

    DataSet dt = new DataSet();
    List<Itempricehistory> converttolist = new List<Itempricehistory>();

    Type elementType = typeof(Itempricehistory);
    DataSet ds = new DataSet();
    DataTable t = new DataTable();
    ds.Tables.Add(t);
    //creating rows in the datatable to that in the list
    foreach (var propInfo in elementType.GetProperties())
    {
        Type ColType = Nullable.GetUnderlyingType(propInfo.PropertyType) ?? propInfo.PropertyType;
        t.Columns.Add(propInfo.Name, ColType);

    }
    //
    foreach (Itempricehistory item in orders)
    {
        DataRow row = t.NewRow();

        foreach (var propInfo in elementType.GetProperties())
        {
            row[propInfo.Name] = propInfo.GetValue(item, null) ?? DBNull.Value;
        }

        t.Rows.Add(row);
    }



  List<Itempricehistory> convertreturntolist = new List<Itempricehistory>();

  t.Columns.Add("DateStr");
  t.AcceptChanges();
   // t.WriteXmlSchema(@"C:\Temp\Amit.xml");
  foreach (DataRow dr in t.Rows)
  {
      DateTime dDate;
      try
      {

          dDate = Convert.ToDateTime(dr["Date"]);
          dr["DateStr"] = dDate.ToString("yyyy-MM");
      }
      catch (Exception)
      {

          throw;
      }
  }


  t.AcceptChanges();

  t = t.AsEnumerable().GroupBy(r => r.Field<string>("DateStr")).Select(g => g.FirstOrDefault()).CopyToDataTable();



 //query to sort by itemname itemcode




  DataTable dtnew = new DataTable();
  DataView view = t.DefaultView;
  view.Sort = "DateStr DESC";
  dtnew = view.ToTable();



    List<Itempricehistory> data = new List<Itempricehistory>();
    foreach (DataRow row in dtnew.Rows)
    {
        data.Add(new Itempricehistory
        {

            CustomerId = row["CustomerId"].ToString(),
            CustomerName = row["CustomerName"].ToString(),
            CustomerOrderNumber = row["CustomerOrderNumber"].ToString(),
            CustomerTaxZone = row["CustomerTaxZone"].ToString(),
            Date = row["DateStr"].ToString(),
            DiscAmt = row["DiscAmt"].ToString(),
            InventoryId = row["InventoryId"].ToString(),
            ItemDescription = row["ItemDescription"].ToString(),
            LineTotal = row["LineTotal"].ToString(),
            OpenQty = row["OpenQty"].ToString(),
            OrderNbr = row["OrderNbr"].ToString(),
            OrderTotal = row["OrderTotal"].ToString(),
            QtyOnShipments = row["QtyOnShipments"].ToString(),
            Quantity = row["Quantity"].ToString(),
            TaxCategory = row["TaxCategory"].ToString(),
            TaxId = row["TaxId"].ToString(),
            TaxRate = row["TaxRate"].ToString(),
            UnitPrice = row["UnitPrice"].ToString(),
            UOM = row["UOM"].ToString(),
            StockCode = row["StockCode"].ToString()
        });
    }
    return data.AsQueryable();
}

推荐答案

< span class =code-string>#windowfritempricehistory)。data( kendoWindow)。open();
("#windowfritempricehistory").data("kendoWindow").open();


#windowfritempricehistory)。data( kendoWindow)。refresh(url);
("#windowfritempricehistory").data("kendoWindow").refresh(url);


#windowfritempricehistory)。data( kendoWindow)。center();

} catch (e){
alert(e);
}
}
("#windowfritempricehistory").data("kendoWindow").center(); } catch (e) { alert(e); } }



C#代码


C# code

public ActionResult Itempricehistorydetails([DataSourceRequest] DataSourceRequest request, string searchvalue)
{
   // searchvalue = "100";
    return Json(Itempricehistorydetails(searchvalue).ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}

private IQueryable<Itempricehistory> Itempricehistorydetails(string stockcode)
{
    string city = (string)(Session["password"]);

    int intstockcode = Convert.ToInt32(stockcode);
    SessionContext sessionContext = CurrentSession;
    string myObUrl = sessionContext.Url;
    string myObUser = sessionContext.LogInUserName;
    string myObPassword = city;
    string custcode = sessionContext.CurrentCustomerId;
    string dtfrom = DateTime.Now.AddYears(-1).ToString("dd/MM/yyyy");
    string dateTo = DateTime.Now.ToString("dd/MM/yyyy");


    string url = ConfigurationManager.AppSettings["BaseServiceUrl"] + "Order/GetSalesHistoryByCustomerByInventoryId? &user=" + myObUser + "&password=" + myObPassword + "&customerId=" + custcode + "&itemCode=" + intstockcode + "&dateFrom=" + dtfrom + "&dateTo=" + dateTo;
    string jSon = CallApi(url);
    List<Itempricehistory> orders = new JavaScriptSerializer().Deserialize<List<Itempricehistory>>(jSon);

    DataSet dt = new DataSet();
    List<Itempricehistory> converttolist = new List<Itempricehistory>();

    Type elementType = typeof(Itempricehistory);
    DataSet ds = new DataSet();
    DataTable t = new DataTable();
    ds.Tables.Add(t);
    //creating rows in the datatable to that in the list
    foreach (var propInfo in elementType.GetProperties())
    {
        Type ColType = Nullable.GetUnderlyingType(propInfo.PropertyType) ?? propInfo.PropertyType;
        t.Columns.Add(propInfo.Name, ColType);

    }
    //
    foreach (Itempricehistory item in orders)
    {
        DataRow row = t.NewRow();

        foreach (var propInfo in elementType.GetProperties())
        {
            row[propInfo.Name] = propInfo.GetValue(item, null) ?? DBNull.Value;
        }

        t.Rows.Add(row);
    }



  List<Itempricehistory> convertreturntolist = new List<Itempricehistory>();

  t.Columns.Add("DateStr");
  t.AcceptChanges();
   // t.WriteXmlSchema(@"C:\Temp\Amit.xml");
  foreach (DataRow dr in t.Rows)
  {
      DateTime dDate;
      try
      {

          dDate = Convert.ToDateTime(dr["Date"]);
          dr["DateStr"] = dDate.ToString("yyyy-MM");
      }
      catch (Exception)
      {

          throw;
      }
  }


  t.AcceptChanges();

  t = t.AsEnumerable().GroupBy(r => r.Field<string>("DateStr")).Select(g => g.FirstOrDefault()).CopyToDataTable();



 //query to sort by itemname itemcode




  DataTable dtnew = new DataTable();
  DataView view = t.DefaultView;
  view.Sort = "DateStr DESC";
  dtnew = view.ToTable();



    List<Itempricehistory> data = new List<Itempricehistory>();
    foreach (DataRow row in dtnew.Rows)
    {
        data.Add(new Itempricehistory
        {

            CustomerId = row["CustomerId"].ToString(),
            CustomerName = row["CustomerName"].ToString(),
            CustomerOrderNumber = row["CustomerOrderNumber"].ToString(),
            CustomerTaxZone = row["CustomerTaxZone"].ToString(),
            Date = row["DateStr"].ToString(),
            DiscAmt = row["DiscAmt"].ToString(),
            InventoryId = row["InventoryId"].ToString(),
            ItemDescription = row["ItemDescription"].ToString(),
            LineTotal = row["LineTotal"].ToString(),
            OpenQty = row["OpenQty"].ToString(),
            OrderNbr = row["OrderNbr"].ToString(),
            OrderTotal = row["OrderTotal"].ToString(),
            QtyOnShipments = row["QtyOnShipments"].ToString(),
            Quantity = row["Quantity"].ToString(),
            TaxCategory = row["TaxCategory"].ToString(),
            TaxId = row["TaxId"].ToString(),
            TaxRate = row["TaxRate"].ToString(),
            UnitPrice = row["UnitPrice"].ToString(),
            UOM = row["UOM"].ToString(),
            StockCode = row["StockCode"].ToString()
        });
    }
    return data.AsQueryable();
}


这篇关于输入按钮不触发字符串参数的事件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆