function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
andyeandye 

ReRender not happening

Hi all,

 

I'm having a problem getting a pageblock and/or a pageblocktable to rerender. I have a table of quote lines displayed on a visualforce page. One of the fields in the quoteline object is called 'Order' as our sales people want to be able to order the lines how they see fit.

 

I'd like to have up and down arrows in this table that, when clicked, move that line up or down (ie. change the 'order' field and rerender the table). However, when I click the buttons, the order is changed but the table isn't rerendered - if I refresh the page I can see the change in order.

 

My code is as follows:

 

VF page:

 

<apex:pageBlock title="Current Quote Lines" id="quotelinetable">
<apex:pageblocktable value="{!quoteLines}" var="quote_line_v2__c" border="1" cellpadding="2">
<apex:column width="80px">
<apex:facet name="header">Move</apex:facet>
<apex:facet name="footer">&nbsp;</apex:facet>
<apex:outputtext >
<apex:commandbutton action="{!moveUp}" reRender="quotelinetable" image="{!URLFOR($Resource.UpArrow)}">
<apex:param name="moveId" value="{!quote_line_v2__c.id}" />
<apex:param name="moveOrder" value="{!quote_line_v2__c.Order__c}" />
</apex:commandbutton>
<apex:commandbutton action="{!moveDown}" reRender="quotelinetable" image="{!URLFOR($Resource.DownArrow)}">
<apex:param name="moveId" value="{!quote_line_v2__c.id}" />
<apex:param name="moveOrder" value="{!quote_line_v2__c.Order__c}" />
</apex:commandbutton>
</apex:outputtext>
</apex:column>

.

.

.

 

 Controller:

 

public pageReference moveUp() {
id qlId = apexpages.currentPage().getParameters().get('moveId');
quote_line_v2__c ql = [select id, Order__c from quote_line_v2__c where id=:qlId];
ql.Order__c -= 1;
update ql;
return null;
}


public pageReference moveDown() {
id qlId = apexPages.currentpage().getParameters().get('moveId');
quote_line_v2__c ql = [select id, Order__c from quote_line_v2__c where id=:qlId];
ql.Order__c
update ql;
return null;
}

 I also need to re-order the lines that follow so I don't get duplicates but that's not a problem. I'll handle that once I get the rerendering sorted.

 

If I hit either the moveUp or moveDown buttons, nothing happens. Nothing is reflected on screen. However, when I refresh the page the order column is changed to reflect the button click.

 

Any help would be hugely appreciated.

 

Thanks,

 

Andy

 

aballardaballard
What are you doing to actually reorder the array quoteLines?  I don't see anything in the posted code that does so... so I'd expect the array to rerender the same as before....
andyeandye

Thankyou! That was just the hint I needed! I assumed updating the records would be enough but completely forgot the table was actually based on that list the was already defined.

 

I've now added code to repopulate the quotelines list with the new objects (reordered) and it all works.

 

Thanks again,

 

Andy