首页 \ 问答 \ 如何从jqGrid调用事件处理程序选择自定义格式化程序(how to call event handler from jqGrid select custom formatter)

如何从jqGrid调用事件处理程序选择自定义格式化程序(how to call event handler from jqGrid select custom formatter)

我有一个带下拉列表的jqGrid。 我用“自定义格式化程序”( dropDownFormatter1 )值填充下拉列表。我得到了,但是根据onchange我需要做一些功能。 我的主要问题是如何在我的下面的代码中添加onchange事件。

这是我的代码:

$("#grid").jqGrid({
    url: bookingStatusurl,
    datatype: "json",
    shrinkToFit: true,
    colModel: [
        { name: 'BookingStatusID', index: ''BookingStatusID'', hidden: true,
            key: true },
        { name: 'BookingStatus', index: 'BookingStatus', width: 260,
            sortable: false },
        { name: 'NumberOfBooking ', index: 'NumberOfBooking', width: 300,
            sortable: false, align: 'right', formatter: 'currency',
            formatoptions: { prefix: "Number Of Booking: "} },
        { name: 'SortOrderType', index: 'SortOrderType', align: 'right',
            edittype: 'select', formatter: **dropDownFormatter1** }
        //As per the on change of my dropDownFormatter1 by subgrid need to change.
    ],
    rowNum: 40,
    rowList: [40, 80, 120]
    //sortname: 'id',
    viewrecords: true,
    //sortorder: "desc",
    autowidth: true,
    multiselect: false,
    shrinkToFit: true,
    height: 'auto',
    altRows: true,
    subGrid: true,
    //loadonce: false,
    //caption: "Pipeline By Booking Status",
    subGridRowExpanded: function (subgrid_id, row_id) {}
});

这是cutom格式化程序的代码:

function dropDownFormatter1(cellvalue, options, rowObject, action) {
   // var statusTypeId = rowObject[0];
    return '<label>Sort Order:</label>' +
        '<select>' +
            '<option value="asc">asc</option>' +
            '<option value="desc">desc</option>' +
        '</select>';
}

请帮帮我。

谢谢。


I have a jqGrid with a dropdown. I am filling the dropdown with "custom formatter"(dropDownFormatter1) value.I am getting that, but as per the onchange i need to do some functionality. My main question is how to add the onchange event in my below code.

Here is my code:

$("#grid").jqGrid({
    url: bookingStatusurl,
    datatype: "json",
    shrinkToFit: true,
    colModel: [
        { name: 'BookingStatusID', index: ''BookingStatusID'', hidden: true,
            key: true },
        { name: 'BookingStatus', index: 'BookingStatus', width: 260,
            sortable: false },
        { name: 'NumberOfBooking ', index: 'NumberOfBooking', width: 300,
            sortable: false, align: 'right', formatter: 'currency',
            formatoptions: { prefix: "Number Of Booking: "} },
        { name: 'SortOrderType', index: 'SortOrderType', align: 'right',
            edittype: 'select', formatter: **dropDownFormatter1** }
        //As per the on change of my dropDownFormatter1 by subgrid need to change.
    ],
    rowNum: 40,
    rowList: [40, 80, 120]
    //sortname: 'id',
    viewrecords: true,
    //sortorder: "desc",
    autowidth: true,
    multiselect: false,
    shrinkToFit: true,
    height: 'auto',
    altRows: true,
    subGrid: true,
    //loadonce: false,
    //caption: "Pipeline By Booking Status",
    subGridRowExpanded: function (subgrid_id, row_id) {}
});

Here is the code for cutom formatter:

function dropDownFormatter1(cellvalue, options, rowObject, action) {
   // var statusTypeId = rowObject[0];
    return '<label>Sort Order:</label>' +
        '<select>' +
            '<option value="asc">asc</option>' +
            '<option value="desc">desc</option>' +
        '</select>';
}

Please help me out.

Thanks.


原文:https://stackoverflow.com/questions/9594626
更新时间:2023-04-06 13:04

最满意答案

很难看出你引用的代码有任何理由。

我唯一能想到的是links中的对象可能很大,或者与稀缺资源相关联,因此尽快释放它们可能很重要(而不是等到循环结束才能释放它们)所有)。 但是(a)如果是这样,最好在创建它时处理每个链接(可能使用生成器来组织代码),而不是在开始处理它之前构建整个链接列表; (b)即使您在处理之前别无选择,只能建立整个列表,清除每个列表条目比弹出列表要便宜:

for i, link in enumerate(links):
    links[i] = None
    ...

(弹出带有n个项目的列表中的第一个元素需要O( n ),尽管在实践中它会相当快,因为​​它是使用memmove实现的。)

即使你绝对坚持在遍历它时反复弹出列表,最好像这样编写循环:

while links:
    link = links.pop(0)
    ...

It's hard to see any justification for the code you quoted.

The only thing I can think of is that the objects in links might be large, or otherwise associated with scarce resources, and so it might be important to free them as soon as possible (rather than waiting until the end of the loop to free them all). But (a) if so, it would be better to process each link as you created it (perhaps using a generator to organize the code), instead of building up the whole list of links before starting to process it; and (b) even if you had no choice but to build up the whole list before processing it, it would be cheaper to clear each list entry than to pop the list:

for i, link in enumerate(links):
    links[i] = None
    ...

(Popping the first element off a list with n items takes O(n), although in practice it will be fairly fast since it's implemented using memmove.)

Even if you absolutely insisted on repeatedly popping a list as you iterated across it, it would be better to write the loop like this:

while links:
    link = links.pop(0)
    ...

相关问答

更多

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)