jqgrid没有从inlineedit发布值 [英] jqgrid not posting values from inlineedit

查看:56
本文介绍了jqgrid没有从inlineedit发布值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页面中有一个jqgrid需要一些帮助





在内联编辑网格中的值后

i do



//此行获取下一行中使用的列名

var name = myGrid.find(' .ui-autocomplete-input')。attr('name');

// getacid()是一个返回正确id的函数

myGrid.jqGrid( 'setCell',lastselProductBrandMaps,name,getacid());

myGrid.jqGrid('saveRow',lastselProductBrandMaps,false);



但当它被发布到控制器时,我刚刚使用setCell更新的id字段丢失了。



i可以确认在调用saveRow之前使用firefox所有行都有其中的正确数据与其他行的格式相同。



i已经将自动完成添加到表单编辑中,它完美地运行,因为我在事件中捕获了postdata并将正确的值放在那里,它的工作原理正确并发回正确的数据。



i想知道为什么它不工作或者是否有任何事件我可以使用内联编辑和修改来捕获数据。

i have a jqgrid in the page and need some help


after inline editing a value in the grid
i do

//this line gets the column name for use in next line
var name = myGrid.find('.ui-autocomplete-input').attr('name');
//getacid() is a function which is returning the right id
myGrid.jqGrid('setCell', lastselProductBrandMaps, name, getacid());
myGrid.jqGrid('saveRow', lastselProductBrandMaps , false);

but when it is posted to the controller the id field which i have just updated using setCell is missing.

i can confirm that using firefox before saveRow is called the row has all the right data in it in the same format as other rows.

i have added the autocomplete already to the form edit and it works perfectly because i have caught postdata on a event and put the right values in there and it works properly and sends right data back.

i want to know why it isnt working or if there any events on which i can catch the data using inline edit and modify.

推荐答案

做了一些googling之后没有找到一个有效的答案



http://stackoverflow.com/questions/12257555/jqgrid-aftersavefunc-not-called-on-saverow [ ^ ]



这也是在saveRow函数中传递额外的id项目作为extradata的一部分。



但是对我来说没有好处,因为我需要更改我的后端代码并编写更多函数,并且每次我想要另一个自动完成字段时对代码进行许多修改。





所以在firefox中使用jquery搞乱后我发现了一个更好的解决方案,如果有其他人需要我想分享。



我做的是< br $> b $ b



after doing some more googling didnt find one answer which worked which is to

http://stackoverflow.com/questions/12257555/jqgrid-aftersavefunc-not-called-on-saverow[^]

which is to also pass extra id item as part of extradata in saveRow function.

this however was no good for me as i would need to change my backend code and write some more functions and make many modifications to code each time i wanted to another autocomplete field.


so after some messing about with jquery in firefox ive found a better fix which i would like to share if anyone else needs.

what i did is


//finds the autocomplete input inside my grid and take its name
var name = myGridBrands.find('.ui-autocomplete-input').attr('name');

//then instead of this line which was messing it up to update element
//myGridBrands.jqGrid('setCell', lastselBrands, name, getacid());

//i do this to update instead 
updateacinput( lastselBrands , name);

//then finally save row again which now works
myGridBrands.jqGrid('saveRow', lastselBrands , false);







jqgrid内联编辑的工作方式是每行输入带有ID的输入格式为

id ='#7_Name'或id ='#2_Size'

所以我发送正确的id和名称并使用jquery .val ()更新价值,现在一切都可以将正确的数据发布到控制器。



现在很好的事情是,我可以使用相当多的地方1 -2行设置






the way jqgrid inline edit works is each row makes inputs with ids in the format of
"id ='#7_Name' " or " id ='#2_Size'"
so i send in the right id and name and use jquery .val() to update value and everything now works posting the right data to controller.

nice thing about this now is that i can use all over the place with pretty much 1-2 lines setup

function updateacinput(id, name) {


' #' + id + ' _' + name).val(g etacid());
}
('#' + id + '_' + name).val(getacid()); }







function getacid() {
    return


' input:hidden 。[ID = \'acid\ ']')VAL();
}
('input:hidden[id=\'acid\']').val(); }


这篇关于jqgrid没有从inlineedit发布值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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