You need to sign in to do that
Don't have an account?

inline edit saving records only for last row of the pagination.
I've created a really simple pagination with search box and created a simple VF page with inline editing on the fields.
Now,depending on what I do between filling in a value in the field and clicking the Save button,it will affect whether the new value is saved or not.
So if I double click on the Last row, amend value, hit enter.The text turns orange and I get the undo icon as expected and Save, it saves the record.But when I edit and click Save for the previous records, the value goes back to its OLD value and is not updated.
Page :
public class PagingTasksController{
public List<Task> tasks;
public Integer CountTotalRecords{get;set;}
public String QueryString {get;set;}
public Integer OffsetSize = 0;
private Integer QueryLimit = 3;
public List<Task> lstTasks;
public String searchText {get;set;}
public PagingTasksController (){
//CountTotalRecords= [select count() from Task];
}
public List<Task> getTasks(){
if(tasks == null){
tasks = new List<Task>();
}
return tasks;
}
public void findTasks(){
String qStr2 = 'Select count() from Task where Subject like \'%'+searchText+'%\' OR Status like \'%'+searchText+'%\'';
CountTotalRecords = Database.countQuery(qStr2);
queryTasks();
}
public void queryTasks(){
String qStr = 'Select OwnerId,Subject,Status,Priority from Task where Subject like \'%'+searchText+'%\' OR Status like \'%'+searchText+'%\' Order By Subject,Status limit ' + QueryLimit + ' offset ' + OffsetSize;
tasks = Database.query(qStr);
tasks.sort();
}
public Boolean getDisablePrevious(){
if(OffsetSize>0){
return false;
}
else return true;
}
public Boolean getDisableNext() {
if (OffsetSize + QueryLimit < countTotalRecords){
return false;
}
else return true;
}
public PageReference Next() {
OffsetSize += QueryLimit;
queryTasks();
return null;
}
public PageReference Previous() {
OffsetSize -= QueryLimit;
queryTasks();
return null;
}
public PageReference save() {
update tasks;
return ApexPages.CurrentPage();
}
}
<apex:page controller="PagingTasksController">
<apex:form >
<apex:pageBlock title="Tasks" id="pgBlock">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" id="saveButton" value="Save"/>
<apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel"/>
</apex:pageBlockButtons>
<apex:inlineEditSupport showOnEdit="saveButton, cancelButton"
hideOnEdit="editButton" event="ondblclick"
changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
<apex:inputText id="searchBox" value="{!searchText}"/>
<apex:commandButton value="Search" reRender="pgTable,pgBlock" action="{!findTasks}"/>
<apex:pageBlockTable value="{!Tasks}" var="tsk" id="pgTable" >
<apex:column >
<apex:outputLink value="{!URLFOR($Action.Task.Delete, tsk.id,['retURL'='/apex/task_test'])}" >Delete</apex:outputLink>
</apex:column>
<apex:column value="{!tsk.Subject}"/>
<apex:column value="{!tsk.Status}"/>
<apex:column value="{!tsk.Priority}"/>
<apex:column value="{!tsk.OwnerId}"/>
</apex:pageBlockTable>
<apex:pageBlockButtons >
<apex:commandButton value="Previous" action="{!Previous}" rerender="pgTable,pgBlock"
status="status" disabled="{!DisablePrevious}" />
<apex:commandButton value="Next" action="{!Next}" reRender="pgTable,pgBlock"
status="status" disabled="{!DisableNext}" />
<apex:actionStatus id="status" startText="Please Wait..."/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
<apex:enhancedlist type="Activity" height="800" rowsPerPage="50" customizable="False"/>
</apex:page>
Class :
public class PagingTasksController{
public List<Task> tasks;
public Integer CountTotalRecords{get;set;}
public String QueryString {get;set;}
public Integer OffsetSize = 0;
private Integer QueryLimit = 3;
public List<Task> lstTasks;
public String searchText {get;set;}
public PagingTasksController (){
//CountTotalRecords= [select count() from Task];
}
public List<Task> getTasks(){
if(tasks == null){
tasks = new List<Task>();
}
return tasks;
}
public void findTasks(){
String qStr2 = 'Select count() from Task where Subject like \'%'+searchText+'%\' OR Status like \'%'+searchText+'%\'';
CountTotalRecords = Database.countQuery(qStr2);
queryTasks();
}
public void queryTasks(){
String qStr = 'Select OwnerId,Subject,Status,Priority from Task where Subject like \'%'+searchText+'%\' OR Status like \'%'+searchText+'%\' Order By Subject,Status limit ' + QueryLimit + ' offset ' + OffsetSize;
tasks = Database.query(qStr);
tasks.sort();
}
public Boolean getDisablePrevious(){
if(OffsetSize>0){
return false;
}
else return true;
}
public Boolean getDisableNext() {
if (OffsetSize + QueryLimit < countTotalRecords){
return false;
}
else return true;
}
public PageReference Next() {
OffsetSize += QueryLimit;
queryTasks();
return null;
}
public PageReference Previous() {
OffsetSize -= QueryLimit;
queryTasks();
return null;
}
public PageReference save() {
update tasks;
return ApexPages.CurrentPage();
}
}
Am I coding my inline edit incorrectly? Can you see anything unusual?
Now,depending on what I do between filling in a value in the field and clicking the Save button,it will affect whether the new value is saved or not.
So if I double click on the Last row, amend value, hit enter.The text turns orange and I get the undo icon as expected and Save, it saves the record.But when I edit and click Save for the previous records, the value goes back to its OLD value and is not updated.
Page :
public class PagingTasksController{
public List<Task> tasks;
public Integer CountTotalRecords{get;set;}
public String QueryString {get;set;}
public Integer OffsetSize = 0;
private Integer QueryLimit = 3;
public List<Task> lstTasks;
public String searchText {get;set;}
public PagingTasksController (){
//CountTotalRecords= [select count() from Task];
}
public List<Task> getTasks(){
if(tasks == null){
tasks = new List<Task>();
}
return tasks;
}
public void findTasks(){
String qStr2 = 'Select count() from Task where Subject like \'%'+searchText+'%\' OR Status like \'%'+searchText+'%\'';
CountTotalRecords = Database.countQuery(qStr2);
queryTasks();
}
public void queryTasks(){
String qStr = 'Select OwnerId,Subject,Status,Priority from Task where Subject like \'%'+searchText+'%\' OR Status like \'%'+searchText+'%\' Order By Subject,Status limit ' + QueryLimit + ' offset ' + OffsetSize;
tasks = Database.query(qStr);
tasks.sort();
}
public Boolean getDisablePrevious(){
if(OffsetSize>0){
return false;
}
else return true;
}
public Boolean getDisableNext() {
if (OffsetSize + QueryLimit < countTotalRecords){
return false;
}
else return true;
}
public PageReference Next() {
OffsetSize += QueryLimit;
queryTasks();
return null;
}
public PageReference Previous() {
OffsetSize -= QueryLimit;
queryTasks();
return null;
}
public PageReference save() {
update tasks;
return ApexPages.CurrentPage();
}
}
<apex:page controller="PagingTasksController">
<apex:form >
<apex:pageBlock title="Tasks" id="pgBlock">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" id="saveButton" value="Save"/>
<apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel"/>
</apex:pageBlockButtons>
<apex:inlineEditSupport showOnEdit="saveButton, cancelButton"
hideOnEdit="editButton" event="ondblclick"
changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
<apex:inputText id="searchBox" value="{!searchText}"/>
<apex:commandButton value="Search" reRender="pgTable,pgBlock" action="{!findTasks}"/>
<apex:pageBlockTable value="{!Tasks}" var="tsk" id="pgTable" >
<apex:column >
<apex:outputLink value="{!URLFOR($Action.Task.Delete, tsk.id,['retURL'='/apex/task_test'])}" >Delete</apex:outputLink>
</apex:column>
<apex:column value="{!tsk.Subject}"/>
<apex:column value="{!tsk.Status}"/>
<apex:column value="{!tsk.Priority}"/>
<apex:column value="{!tsk.OwnerId}"/>
</apex:pageBlockTable>
<apex:pageBlockButtons >
<apex:commandButton value="Previous" action="{!Previous}" rerender="pgTable,pgBlock"
status="status" disabled="{!DisablePrevious}" />
<apex:commandButton value="Next" action="{!Next}" reRender="pgTable,pgBlock"
status="status" disabled="{!DisableNext}" />
<apex:actionStatus id="status" startText="Please Wait..."/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
<apex:enhancedlist type="Activity" height="800" rowsPerPage="50" customizable="False"/>
</apex:page>
Class :
public class PagingTasksController{
public List<Task> tasks;
public Integer CountTotalRecords{get;set;}
public String QueryString {get;set;}
public Integer OffsetSize = 0;
private Integer QueryLimit = 3;
public List<Task> lstTasks;
public String searchText {get;set;}
public PagingTasksController (){
//CountTotalRecords= [select count() from Task];
}
public List<Task> getTasks(){
if(tasks == null){
tasks = new List<Task>();
}
return tasks;
}
public void findTasks(){
String qStr2 = 'Select count() from Task where Subject like \'%'+searchText+'%\' OR Status like \'%'+searchText+'%\'';
CountTotalRecords = Database.countQuery(qStr2);
queryTasks();
}
public void queryTasks(){
String qStr = 'Select OwnerId,Subject,Status,Priority from Task where Subject like \'%'+searchText+'%\' OR Status like \'%'+searchText+'%\' Order By Subject,Status limit ' + QueryLimit + ' offset ' + OffsetSize;
tasks = Database.query(qStr);
tasks.sort();
}
public Boolean getDisablePrevious(){
if(OffsetSize>0){
return false;
}
else return true;
}
public Boolean getDisableNext() {
if (OffsetSize + QueryLimit < countTotalRecords){
return false;
}
else return true;
}
public PageReference Next() {
OffsetSize += QueryLimit;
queryTasks();
return null;
}
public PageReference Previous() {
OffsetSize -= QueryLimit;
queryTasks();
return null;
}
public PageReference save() {
update tasks;
return ApexPages.CurrentPage();
}
}
Am I coding my inline edit incorrectly? Can you see anything unusual?
It would have been great if you would have provided your response on the original thread where you posted your requirements and I replied :-)
Now for inline edit instead of putting value to column directly you need to output value to outputfield like below.
it shoud resolve the issue you are facing.
All Answers
It would have been great if you would have provided your response on the original thread where you posted your requirements and I replied :-)
Now for inline edit instead of putting value to column directly you need to output value to outputfield like below.
it shoud resolve the issue you are facing.
Actually searching is done by SOQL only, you have used 'Select OwnerId,Subject,Status,Priority from Task where Subject like \'%'+searchText+'%\' OR Status like \'%'+searchText+'%\' Order By Subject,Status limit ' + QueryLimit + ' offset ' + OffsetSize;
hence it will search on all fields in where clause for whatever text you provide even single one.
For blank search, it will show all tasks as in SOQL where clause it would return all results.