如何从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 theonchange
i need to do some functionality. My main question is how to add theonchange
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
最满意答案
很难看出你引用的代码有任何理由。
我唯一能想到的是
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) ...
相关问答
更多-
您只需要在某个时刻调用生成器对象(您称之为f3 )。 您可以在创建它时调用它: f3 = inf_repeat(3)() 甚至在inf_repeat里面 # change last line to this return func() 将yield放在函数中使它成为一个生成函数 - 也就是说,一个函数在被调用时返回一个生成器。 如果你想得到发电机,你需要在某个时刻调用你的发电机功能。 顺便说一下,你的实现是不必要的复杂。 没有所有装饰器和嵌套函数,您可以更简单地获得所需的行为: def inf_repe ...
-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
您可以使用GeneratorType从类型: >>> import types >>> types.GeneratorType
>>> gen = (i for i in range(10)) >>> isinstance(gen, types.GeneratorType) True You can use GeneratorType from types: >>> import types >>> types.GeneratorType 这是我得到它的工作。 我没有试图扩展函数定义中Edge生成器的参数,而是简单地传递了kwargs生成器,并在Edge生成器主体中的kwargs生成器上添加了一个循环,并在创建边时扩展了参数。 def line_from_file_generator(file_name): with open(file_name) as text_file: for line in text_file: yield line def kwargs_from_delimit ...您分配给req[key]的生成器表达式绑定在key变量上。 但循环中的key从“A”变为“B”。 当迭代第一个生成器表达式时,即使在创建它时key是'A',它也会在其if条件中将key评估为'B'。 绑定到变量的值而不是引用的传统方法是将表达式用默认值包装到lambda表达式中,然后立即调用它。 for key in d: req[key] = (lambda key=key: (p for p in d[key]['param'] if d[key]['param'][p].get('req', ...当您遍历生成器的元素时,您将使用它们。 尝试这个: len(list(first_hundred_primes)) > 0 => True len(list(first_hundred_primes)) > 0 => False 也就是说,你第一次使用元素时会消耗元素(迭代它们),或者列出所有元素,最多5个元素,因此生成器在此之后不再生成5。 第二次之后,它将不再生成任何东西。 您的选择: 在使用之前将您的生成器转换为列表(或集合): first_hundred_primes = list(first_h ...child.listChildren()将返回一个生成器对象,而不是实际的子对象。 所以你可能想做类似的事情: def listChildren(self): yield self for child in self.children: for c in child.listChildren(): yield c raise StopIteration # PS: you don't need to do that explicitly 或者,如果您使用Python 3.3 ...生成函数的名称(如果有)作为字符串存储在__name__属性中。 如果字符串是你需要的全部,那么你已经完成了。 要获得实际的函数对象,它很复杂。 生成器本身不包含对函数对象的任何引用,并且逻辑使用对代码对象的引用来操作。 function object (`gen1`) ----->^ generator object (`g1`) -----------╯ 使用生成器函数的原始名称,您可以想象在包含 ...
很难看出你引用的代码有任何理由。 我唯一能想到的是links中的对象可能很大,或者与稀缺资源相关联,因此尽快释放它们可能很重要(而不是等到循环结束才能释放它们)所有)。 但是(a)如果是这样,最好在创建它时处理每个链接(可能使用生成器来组织代码),而不是在开始处理它之前构建整个链接列表; (b)即使您在处理之前别无选择,只能建立整个列表,清除每个列表条目比弹出列表要便宜: for i, link in enumerate(links): links[i] = None ... (弹出带有n ...当Python 解析 def语句时,它决定代码是定义生成器还是函数。 如果代码包含yield表达式,那么它是一个生成器。 因此,当调用生成器函数a ,它返回generator object b 。 在调用b.next()之前,不会执行def语句中的代码。 考虑这两个功能: def gen(): print('In gen') yield 1 yield 2 def func(): print('In gen') 虽然gen和func都是函数,但Pytho ...相关文章
更多- jQuery表格插件jqGrid(jquery.jqGrid.js)
- jqgrid 中组合框的值和key
- Solr学习笔记之5、Component(组件)与Handler(处理器)学习
- Custom SOLR Search Components - 2 Dev Tricks
- Solr: a custom Search RequestHandler
- My W3C Custom Mapping File
- 自己封装的一个Solr Data Import Request Handler Scheduler
- Struts2标签select的使用
- jqgrid删除按钮出问题
- storm事件管理器EventManager源码分析-event.clj
最新问答
更多- 您如何使用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)