?
Solved

Need to read from table created with ng-repeat

Posted on 2013-12-02
3
Medium Priority
?
398 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 400 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 1600 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

Major Serverless Shift

Comparison of major players like AWS, Microsoft Azure, IBM Bluemix, and Google Cloud Platform

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

765 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