2016-09-18 90 views
0

我试图在内联编辑器子列表类型的子列表中添加标记全部/取消标记全部按钮。下面我添加了一个列表类型子列表的代码,它不会在内联编辑器子列表中工作。任何人都可以帮助找到这个?如何在内联编辑器子类列表中添加标记全部/取消标记全部按钮netsuite

function button1Func(type) { 
if (type=='edit' || 'view') 
    { 
     var record = nlapiLoadRecord(nlapiGetRecordType(), nlapiGetRecordId()); 
     var intCount = record.getLineItemCount('item'); 
     var headrow = document.getElementById("item_headerrow"); 
     var head = headrow.insertCell(0); 
     head.innerHTML ="Select"; 
     for (var rep = 1; rep <= intCount; rep++) 
      { 
       var row = document.getElementById("item_row_"+rep); 
       var x = row.insertCell(0); 
       var newCheckbox = document.createElement("INPUT"); 
       newCheckbox.setAttribute("type", "checkbox"); 
       newCheckbox.setAttribute("id", "select_CheckBox"+rep); 
       x.appendChild(newCheckbox); 
      } 
    } 
} 

function button2Func(type) { 
if (type=='edit' || 'view') 
    { 
     var record = nlapiLoadRecord(nlapiGetRecordType(), nlapiGetRecordId()); 
     var intCount = record.getLineItemCount('item'); 
     for (var rep = 1; rep <= intCount; rep++) 
      { 
       var repId = record.getLineItemValue('item', 'item', rep); 
       if(document.getElementById("select_CheckBox"+rep).checked==true){ 
        makecopyfun(repId); 
       } 
       else 
       { 
        continue; 
       } 
      } 
     alert("Success"); 
    } 
} 

function makecopyfun(repId){ 
    var record = nlapiLoadRecord(nlapiGetRecordType(), nlapiGetRecordId()); 
    var intCount = record.getLineItemCount('item'); 
    record.insertLineItem('item',intCount + 1); 
    alert (intCount); 
    record.setCurrentLineItemValue('item','item',repId); 
    record.commitLineItem('item'); 
    var id = nlapiSubmitRecord(record, true); 
} 

回答

1

不确定通过API,因为没有记录对象,你可以尝试使用jQuery。

0

我确实想出了其他想法,因为您可以使用该字段帮助您标记/取消标记子列表下的所有行。您可以将子标签添加到表单,并在子标签下添加字段和子列表。稍后,您可以在该字段上应用脚本,这将帮助您标记/取消标记所有子列表行。

下面是代码...

form.addSubTab( 'custpage_tab', '主标签'); form.addField('custpage_chkmark','checkbox','Mark/Unmark All',null,'custpage_tab'); form.addSubList('custpage_sublst','inlineeditor','SampleSubList','custpage_tab');

+0

我无法创建新的子列表。我必须在报价单模块的ITEM清单上实现此功能。你在谈论的是一个新的子列表。在这种情况下,我们可以使用addMarkAllButtons(); API来创建此选项。如果您知道如何在内联编辑器子列表中添加markAll按钮,请帮助我。 @ user6291223 – ndh

+0

好吧,我们必须做更多的工作...请按照下面的答案为它..详细写它。 – UDAY

0

首先编写以下代码&创建userEvent脚本并在beforeLoad事件中应用函数名称(initnoload)。 然后在报价上部署该脚本。

function initonload(type, form, request) { 
if (type=='edit' || type=='view') { 

    var list = form.getSubList("item"); 
    list.addButton('custpage_markmark','Mark all','markall();'); //markall(); is function name from the client script 
    list.addButton('custpage_unmarkmark','Unmark all','unmarkall();'); //unmarkall(); is function name from client script 
    form.setScript('customscript_mark_all_item_quote'); // 'customscript_mark_all_item_quote' is the ID of script 

} 
} 

上面的代码将两个按钮添加到子列表和它们的作用在客户端脚本,其ScriptId我们已经定义得到执行。

现在编写下面的代码&创建客户端脚本(注意:只保存客户端脚本,不要指定任何事件函数名称,不要部署它)。

function markall() { 

    var count=nlapiGetLineItemCount('item'); //gets the count of lines 
    for(var i=1;i<=count;i++) { 
     nlapiSelectLineItem('item',i); 
     nlapiSetCurrentLineItemValue('item','custcol_checkbox_field','T',true,true); //'custcol_checkbox_field' is checkbox's field ID. 
    } 
    nlapiCommitLineItem('item'); 
} 
function unmarkall() { 

    var count=nlapiGetLineItemCount('item'); 
    for(var i=1;i<=count;i++) { 
     nlapiSelectLineItem('item',i); 
     nlapiSetCurrentLineItemValue('item','custcol_checkbox_field','F',true,true); //'custcol_checkbox_field' is checkbox's field ID. 
    } 
    nlapiCommitLineItem('item'); 
} 

保存客户端脚本后,请粘贴在用户事件的form.setScript(“客户端脚本ID”)的标识。功能

我希望这会帮助你。

请让我知道你是否面临任何困难。

谢谢。

+0

谢谢你的帮助。我最后一天得到了这个工作。但我以不同的方式来做这件事。我使用JavaScript创建了一个复选框,并为客户提供了一个选择选项。现在我可以选中复选框并将行复制到列表的末尾。我现在面临的问题是,它仅在刷新网页时更新,如果我保存记录而不刷新它,则承诺项目不会更新。我将在问题中添加我的代码,请告诉我如何在不刷新页面的情况下执行此操作。 @ user6291223 – ndh

+0

是的,你所说的是正确的。在这种情况下,您正在加载记录,将更改作为选择行并提交记录。 可以说这是您正在执行的后端过程。现在,当您最初加载记录时,页面显示没有选择行,但是当您加载并选择行时,此过程会保存更改的记录,但是您的WEB页仍然会显示加载的页面.... 您已经进行了更改,但要查看那些您必须重新加载页面的页面,以帮助您从记录中获取新值。 – UDAY

+0

如果你想在你的按钮的性能后刷新当前页面,我建议你通过suitelet来帮助你重新加载页面。 请让我知道这个帮助与否。 – UDAY