Javascript 获取/设置PageBlockTable中字段的值
我在visualforce页面中有一个pageBlockTable,在该表中,我允许用户通过JQuery.sortable重新排列行的顺序 不,我想将此排序存储在page save上,因此我在Salesforce中的产品上创建了一个名为sort_order的新参数,它是一个数字字段 我想更新这个字段,它位于表中,并且在每次拖动行时最终都会被隐藏,以便在保存时存储所有内容 我有下面的代码,我正试图在表中循环并适当地更新字段,但我无法制定用于设置字段值的JQuery语法 以下是创建表的代码:Javascript 获取/设置PageBlockTable中字段的值,javascript,jquery,dom,salesforce,apex-code,Javascript,Jquery,Dom,Salesforce,Apex Code,我在visualforce页面中有一个pageBlockTable,在该表中,我允许用户通过JQuery.sortable重新排列行的顺序 不,我想将此排序存储在page save上,因此我在Salesforce中的产品上创建了一个名为sort_order的新参数,它是一个数字字段 我想更新这个字段,它位于表中,并且在每次拖动行时最终都会被隐藏,以便在保存时存储所有内容 我有下面的代码,我正试图在表中循环并适当地更新字段,但我无法制定用于设置字段值的JQuery语法 以下是创建表的代码:
<apex:pageBlock title="Selected {!$ObjectType.Product2.LabelPlural}" id="selected">
<apex:variable value="{!1}" var="index">
<apex:pageblockTable value="{!shoppingCart}" var="s" id="shopping_cart" rowClasses="cartRow">
<tr data-SFid="{!index}">
<apex:column headerValue="{!$ObjectType.OpportunityLineItem.Fields.Description.Label}">
<apex:inputField id="item_description" value="{!s.Description}" required="false"/>
</apex:column>
<apex:column headerValue="Current ID">
<apex:inputField id="Current_ID" value="{!s.Sort_Order__c}" style="width:70px" required="false" onkeyup="refreshTotals();"/>
</apex:column>
<apex:column headerValue="Updated ID" value="{!index}" />
<apex:column >
<apex:commandLink value="Remove" action="{!removeFromShoppingCart}" reRender="selected,searchResults" immediate="true">
<!-- this param is how we send an argument to the controller, so it knows which row we clicked 'remove' on -->
<apex:param value="{!s.PriceBookEntryId}" assignTo="{!toUnselect}" name="toUnselect"/>
</apex:commandLink>
<apex:variable value="{!index+1}" var="index">
</apex:variable>
</apex:column>
<apex:column headerValue="{!$ObjectType.Product2.LabelPlural}" value="{!s.PriceBookEntry.Product2.Name}"/>
<apex:column headerValue="{!$ObjectType.OpportunityLineItem.Fields.Quantity.Label}">
<apex:inputField value="{!s.Quantity}" style="width:70px" required="true" onkeyup="refreshTotals();"/>
</apex:column>
<apex:column headerValue="{!$ObjectType.OpportunityLineItem.Fields.UnitPrice.Label}">
<apex:inputField value="{!s.UnitPrice}" style="width:70px" required="true" onkeyup="refreshTotals();"/>
</apex:column>
</tr>
</apex:pageblockTable>
</apex:variable>
非常感谢您的帮助,因为我更喜欢Objective,而不是Javascript/JQuery
谢谢
加雷斯
$( "[id$=shopping_cart] tbody" ).sortable({
update: function(event, ui) {
//init();
i = 0;
$("[id$=shopping_cart] tbody tr.cartRow").each(function() {
$this = $(this)
var value = $(this).find('Current_ID');
var value2 = $(value).find('value');
console.log("Checking Row " + i);
console.log(value);
console.log(value2).value;
i++;
});
})
$( "[id$=shopping_cart] tbody" ).sortable({
update: function(event, index) {$("[id$=shopping_cart] tbody tr .cartRow").each(function(index, value) {$(value).val(index); });}
})