我试图连接jQuery插件http://www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/与Catalog_Products表,我做到了。我到grid.js文件中注入代码(jQuery代码):Magento Catalog_Products在jQuery中的拖放表admin
...
initGrid : function(){
if(this.preInitCallback){
this.preInitCallback(this);
}
if($(this.containerId+this.tableSufix)){
this.rows = $$('#'+this.containerId+this.tableSufix+' tbody tr');
for (var row=0; row<this.rows.length; row++) {
if(row%2==0){
Element.addClassName(this.rows[row], 'even');
}
Event.observe(this.rows[row],'mouseover',this.trOnMouseOver);
Event.observe(this.rows[row],'mouseout',this.trOnMouseOut);
Event.observe(this.rows[row],'click',this.trOnClick);
Event.observe(this.rows[row],'dblclick',this.trOnDblClick);
if(this.initRowCallback){
try {
this.initRowCallback(this, this.rows[row]);
} catch (e) {
if(console) {
console.log(e);
}
}
}
}
}
if(this.sortVar && this.dirVar){
var columns = $$('#'+this.containerId+this.tableSufix+' thead a');
for(var col=0; col<columns.length; col++){
Event.observe(columns[col],'click',this.thLinkOnClick);
}
}
this.bindFilterFields();
this.bindFieldsChange();
if(this.initCallback){
try {
this.initCallback(this);
}
catch (e) {
if(console) {
console.log(e);
}
}
}
// Drag and drop
jQuery(document).ready(function() {
// Initialise the table
jQuery("#catalog_category_products_table tbody").tableDnD({
onDrop: function() {
jQuery("#catalog_category_products_table tbody tr").each(function(index) {
jQuery("#catalog_category_products_table tbody tr td input.input-text:eq("+index+")").removeAttr('value');
jQuery("#catalog_category_products_table tbody tr td input.input-text:eq("+index+")").attr('value', index + 1);
});
}
});
});
},
getContainerId : function(){
return this.containerId;
},
...
下降后我排序函数的输入值如1,2-排序......这工作得很好。问题是,当我保存这个产品时,新的输入值没有保存,我想这是因为magento我使用了一些按键,改变绑定功能。我将非常感谢帮助解决这个问题。
Thx非常多这是工作,但sitll我没有得到这个值到数据库中。你能帮助我吗? – 2012-08-16 11:33:06
在上一个声明中,我提到了有关禁用的元素。你尝试过调试吗? – 2012-08-16 15:07:29
是的,我让它工作:) thx – 2012-08-21 12:46:10