Solved

Need to read from table created with ng-repeat

Posted on 2013-12-02
3
396 Views
Last Modified: 2013-12-03
I have the below data that is filled using ng-repeat

<tr ng-repeat="task in taskMasterList" on-repeat-finished>
	<td><input type="checkbox" /></td>
	<td>{{ task.TaskCategory }}</td>
	<td>{{ task.TaskDescription }}</td>
	<td><input ng-model="dueDate"></td>
	<td>
		<select ng-model="task.TaskStatus" >                                         
			<option value="1">Open</option>
			<option value="2">In Progress</option>
			<option value="3">Complete</option>
			<option value="4">Deleted</option>
		</select>
	</td>
</tr>
<button ng-click="MasterTaskListSave($event)">Save</button>

Open in new window

-----------------------

This code successfully gets the data from the database (A web service is set up)



var masterTasks = TasksService.GetListingMasterTasks(
{}
, function (data) {
	$scope.taskMasterList = data;          
}
, function (data, status) {
	alert('Failed');
});

Open in new window


I now need to look through the data and get all the rows that are checked
where       <td><input type="checkbox" /></td>  and get the valuses in

<select ng-model="task.TaskStatus"

Any advice is appreciated
0
Comment
Question by:Charles Baldo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 7

Assisted Solution

by:cstsang
cstsang earned 100 total points
ID: 39691845
I give you a sample code for your reference,hope it can help:
<html>
<body>
	<script language=javascript>
		function hh()
		{
			var table=document.getElementById("qq"); //get the table object
			var dropDownBox,cells,checkBox;
			for (i=0;i<table.rows.length;i++)   //loop all rows
			{
				cells=table.rows[i].cells;
				checkBox=cells[0].firstChild; //get the check box object
				isCheck=checkBox.checked;     //check whether the check box is checked
				dropDownBox=cells[1].firstChild; //get the dropdown box object
				dropDownBoxValue=dropDownBox.options[dropDownBox.selectedIndex].value; //get the dropdown box value
				alert("Check box is checked "+isCheck+",Drop Down Box Value="+dropDownBoxValue);
			}
		}	
	</script>
	<table id="qq">
		<tr>
			<td><input type="checkbox" checked/></td>
			<td><select>
				 <option selected value="1">Open</option>
                  <option value="2">In Progress</option>
                  <option value="3">Complete</option>
                  <option value="4">Deleted</option>
            	</select>
      		</td>
		</tr>
		<tr>
			<td><input type="checkbox" /></td>
			<td><select>
				 <option  value="1">Open</option>
                  <option selected value="2">In Progress</option>
                  <option value="3">Complete</option>
                  <option value="4">Deleted</option>
            	</select>
      		</td>
		</tr>
	</table>	
	<input type=button onclick="hh()" value="go">
</body>
</html>	

Open in new window

0
 
LVL 82

Accepted Solution

by:
leakim971 earned 400 total points
ID: 39692214
With : <input type="checkbox" ng-model="task.isChecked" />

You may use something like :
        $scope.MasterTaskListSave = function(evt) {
            var taskListToSave = [];
            for(var i=0;i<$scope.taskMasterList.length;i++) {
                var task = $scope.taskMasterList[i];
                if(task.isChecked) {
                    taskListToSave.push(task);
                    // for the demo
                    alert(task.TaskStatus);
                }
            }
            // taskListToSave contains all selected task with their TaskStatus
            // you can send it to server side to save it now
            save(taskListToSave);
        }

Open in new window

0
 

Author Closing Comment

by:Charles Baldo
ID: 39692387
Thank you all
0

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
This article discusses how to create an extensible mechanism for linked drop downs.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question