jQuery プラグインhttp://www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/を Catalog_Products テーブルに接続しようとしていますが、それを行いました。このコード (jQuery コード) を grid.js ファイルに挿入します。
...
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 がキープレスを使用してバインド機能を変更したためだと思います。この問題で私を助けてくれてとても感謝しています。