You need to sign in to do that
Don't have an account?
Gaurav Gulanjkar 18
Inputcheck box select/refresh data
Hi All,
I have a requirement where I need to show task list of a case on visualforce page with checkbox's for each task. When I select the tasks, On select of the check box I need to update the task status in the database and refresh the table back on the visualforce page. I have written the logic to display the task list on the VF. How can I update the database on select of the checkbox and refresh the page.
Controller:
Visualforce page:
Thanks,
Gaurav
I have a requirement where I need to show task list of a case on visualforce page with checkbox's for each task. When I select the tasks, On select of the check box I need to update the task status in the database and refresh the table back on the visualforce page. I have written the logic to display the task list on the VF. How can I update the database on select of the checkbox and refresh the page.
Controller:
public class RelatedTaskController { public List<taskWrapper> taskList {get; set;} public RelatedTaskController(){ getTasks(); } public List<taskWrapper> getTasks() { if(taskList == null) { taskList = new List<taskWrapper>(); for(Task c: [select Id, Owner.Name,Status,Subject from Task where WhatId =: '5008E000001EOg6QAG']) { taskList.add(new taskWrapper(c)); } } return taskList; } public class taskWrapper { public Task tsk {get; set;} public Boolean selected {get; set;} public taskWrapper(Task t) { tsk = t; selected = false; } } }
Visualforce page:
<apex:page controller="RelatedTaskController"> <apex:form > <apex:pageBlock > <apex:pageBlockTable value="{!taskList}" var="t" id="table"> <apex:column > <apex:inputCheckbox value="{!t.selected}"/> </apex:column> <apex:column value="{!t.tsk.Owner.Name}" /> <apex:column value="{!t.tsk.Subject}" /> <apex:column value="{!t.tsk.Status}" /> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
Thanks,
Gaurav
You will need to add an on-change event to your inputCheckbox that will call an Apex Controller method which will handle your logic. Also, you can rerender the table. It works like this:
Hope this helps!
Happy coding!
Best regards,
Martijn Schwärzer