问:
each function not working as expected
So what I try to do is the following:

I got some items in 3 columns and default positioning (position:static).
And I'm trying to transition them to top:0; left:0 of the page.
Transitions between different positions (absolute and static) are not possible in CSS3, so I tried a jQuery workaround:

```<code>$(".item").each(function(){
  var items = $(this);
  $(this).css({
      'width': items.width(),
      'height': items.height(),
      'position': 'absolute',
      'top': items.offset().top,
      'left': items.offset().left
  });
});
</code>```

What this is supposed to do, is to take every item with class item and "duplicate" it at the exisiting position with position:absolute
This is working perfectly for one item. But as soon as I got multiple items, it simply stacks them at the position of the  first item...

Here's a fiddle:

$(".item").each(function(){
  var items = $(this);
  $(this).css({
      'width': items.width(),
      'height': items.height(),
      'position': 'absolute',
      'top': items.offset().top,
      'left': items.offset().left
  });
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>#items{
    -webkit-column-count: 3;
    -webkit-column-gap: 10px;
    -moz-column-count: 3;
    -moz-column-gap: 10px;
    column-count: 3;
    column-gap: 10px;
}
.item{
    width:100%;
    height:20px;
    text-align:center;
    overflow:hidden;
    margin:0 0 10px 0;
    border:1px solid black;
}</code>```

1

2

3

4

4

```

My desired result is that jQuery takes every item, gets its position on the page, and replaces the CSS, so it's at the same position as before, just with position:absolute, so I can transition it to top:0;left:0; afterwards.

答:
This "Transitions between different positions (absolute and static) are not possible in CSS3, so I tried a jQuery workaround:" can be worked around by having static by default, and then appending a class that has absolute. Then the CSS attribute "transition" will work.

fiddle here https://jsfiddle.net/nikoimp/vL9bahra/

```<code><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>$("#1").addClass('1');
$("#2").addClass('2');
$("#3").addClass('3');
$("#4").addClass('4');
$("#5").addClass('5');</code>```

    #items{
        -webkit-column-count: 3;
        -webkit-column-gap: 10px;
        -moz-column-count: 3;
        -moz-column-gap: 10px;
        column-count: 3;
        column-gap: 10px;
    }
    .item{
        -webkit-transition: width 2s;
        transition: width 2s;
        width:100%;
        height:20px;
        text-align:center;
        overflow:hidden;
        margin:0 0 10px 0;
        border:1px solid black;
    }
    .1 {
        position: absolute;
        background: red;
    }```
<pre class="snippet-code-html lang-html prettyprint-override"><code>    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

    <div id="items">
      <div class="item" id="1">1</div>
      <div class="item" id="2">2</div>
      <div class="item" id="3">3</div>
      <div class="item" id="4">4</div>
   <div class="item" id="5">4</div>
    </div></code>```

```

Title: each function not working as expected

Body:
So what I try to do is the following:

I got some items in 3 columns and default positioning (position:static).
And I'm trying to transition them to top:0; left:0 of the page.
Transitions between different positions (absolute and static) are not possible in CSS3, so I tried a jQuery workaround:

$(".item").each(function(){
  var items = $(this);
  $(this).css({
      'width': items.width(),
      'height': items.height(),
      'position': 'absolute',
      'top': items.offset().top,
      'left': items.offset().left
  });
});

What this is supposed to do, is to take every item with class item and "duplicate" it at the exisiting position with position:absolute
This is working perfectly for one item. But as soon as I got multiple items, it simply stacks them at the position of the  first item...

Here's a fiddle:

$(".item").each(function(){
  var items = $(this);
  $(this).css({
      'width': items.width(),
      'height': items.height(),
      'position': 'absolute',
      'top': items.offset().top,
      'left': items.offset().left
  });
});

#items{
    -webkit-column-count: 3;
    -webkit-column-gap: 10px;
    -moz-column-count: 3;
    -moz-column-gap: 10px;
    column-count: 3;
    column-gap: 10px;
}
.item{
    width:100%;
    height:20px;
    text-align:center;
    overflow:hidden;
    margin:0 0 10px 0;
    border:1px solid black;
}

1

2

3

4

4

My desired result is that jQuery takes every item, gets its position on the page, and replaces the CSS, so it's at the same position as before, just with position:absolute, so I can transition it to top:0;left:0; afterwards.

Body:
This "Transitions between different positions (absolute and static) are not possible in CSS3, so I tried a jQuery workaround:" can be worked around by having static by default, and then appending a class that has absolute. Then the CSS attribute "transition" will work.

fiddle here https://jsfiddle.net/nikoimp/vL9bahra/

$("#1").addClass('1');
$("#2").addClass('2');
$("#3").addClass('3');
$("#4").addClass('4');
$("#5").addClass('5');

    #items{
        -webkit-column-count: 3;
        -webkit-column-gap: 10px;
        -moz-column-count: 3;
        -moz-column-gap: 10px;
        column-count: 3;
        column-gap: 10px;
    }
    .item{
        -webkit-transition: width 2s;
        transition: width 2s;
        width:100%;
        height:20px;
        text-align:center;
        overflow:hidden;
        margin:0 0 10px 0;
        border:1px solid black;
    }
    .1 {
        position: absolute;
        background: red;
    }

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

    <div id="items">
      <div class="item" id="1">1</div>
      <div class="item" id="2">2</div>
      <div class="item" id="3">3</div>
      <div class="item" id="4">4</div>
   <div class="item" id="5">4</div>
    </div>


来源: stackexchange

问:
Placing DIV on the right side of form
I have a div in a form and i want to place the div on the right side of the form and the div must be fixed on the right side with the button. I don't know if this can be done but how can i get this done.

HTML

```<code><form class="form-horizontal" method="post">
   <div class="form-group">
      <label for="name" class="col-lg-1 control-label"> Name</label>
      <div class="col-lg-6">
         <input type="text" class="typeahead form-control" id="name" placeholder="Name" name="name" required>
      </div>
   </div>
   <!--i want to move this div to the right side of the form and fixed-->
   <div  style="background-color:white" class="move-right" id="move-right">
      <legend style="text-align: center" >Heading <span></span></legend>
   </div>
   <div>
      <button type="submit" class="btn ">Save</button>
   </div>
</form>
</div>
</code>```

答:
If  the content of the right should not overlap the other content you need:

.move-right { float:right; } in the css.
And reorder the html code to place the floating element above the others:

```<code>    <form class="form-horizontal" method="post">
       <div  style="background-color:white" class="move-right" id="move-
right">
          <legend style="text-align: center" >Heading <span></span></le zgend>
       </div>
       <div class="form-group">
          <label for="name" class="col-lg-1 control-label"> Name</label>
          <div class="col-lg-6">
             <input type="text" class="typeahead form-control" id="name"
placeholder="Name" name="name" required>
          </div>
       </div>
       <div>
          <button type="submit" class="btn ">Save</button>
       </div>
    </form>
</code>```

otherwise, if the contents can overlap:

use the .move-right { position: absolute; right: 0px; } and .form-horizontal { position: relative; } css code.

ContentLicense: CC BY-SA 3.0

Title: Placing DIV on the right side of form

Body:
I have a div in a form and i want to place the div on the right side of the form and the div must be fixed on the right side with the button. I don't know if this can be done but how can i get this done.

HTML

<form class="form-horizontal" method="post">

       Name

         <input type="text" class="typeahead form-control" id="name" placeholder="Name" name="name" required>

      <legend style="text-align: center" >Heading </legend>

      <button type="submit" class="btn ">Save</button>

</form>

Body:
If  the content of the right should not overlap the other content you need:

.move-right { float:right; } in the css.
And reorder the html code to place the floating element above the others:

    <form class="form-horizontal" method="post">
       <div  style="background-color:white" class="move-right" id="move-
right">
          <legend style="text-align: center" >Heading <span></span></le zgend>
       </div>
       <div class="form-group">
          <label for="name" class="col-lg-1 control-label"> Name</label>
          <div class="col-lg-6">
             <input type="text" class="typeahead form-control" id="name"
placeholder="Name" name="name" required>
          </div>
       </div>
       <div>
          <button type="submit" class="btn ">Save</button>
       </div>
    </form>

otherwise, if the contents can overlap:

use the .move-right { position: absolute; right: 0px; } and .form-horizontal { position: relative; } css code.


问:
Python Select Specific Row and Column
I wish to select a specific row and column from a CSV file in python.  If the value is blank, I want to perform one action, and if the value is not blank, I want to perform another action.

I think the code should look something like this:

```<code>inputFile = 'example.csv'
reader = csv.reader(inputFile, 'rb')
for row in reader:
    if row[5][6] == '':              ==>  (I mean select value the 5th row and 6th column)
        (do this)
    else:
        (do that)
</code>```

Any help or guidance on this topic would be helpful -- I've done a similar task using lists; however, since the CSV file is raw, I don't know what to do.

答:
My names.csv file.

```<code>number;first_name;last_name
1;Baked;Beans
2;Lovely;Spam
3;Wonderful;Spam
4;Up;Spam
5;Baked;Beans
6;Lovely;Spam
7;Wonderful;Spam
8;Down;Spam
9;Baked;Beans
</code>```

My code in python

```<code>import csv
L = [0, 5, 7]

with open('names.csv',"r") as f:
    r = csv.DictReader(f, delimiter =";")
    for i, line in enumerate(r):
        if i in L:    # or (i+2) in L: from your second example
            print (line)
            print (line['first_name'], line['last_name'])
</code>```

Title: Python Select Specific Row and Column

Body:
I wish to select a specific row and column from a CSV file in python.  If the value is blank, I want to perform one action, and if the value is not blank, I want to perform another action.

I think the code should look something like this:

inputFile = 'example.csv'
reader = csv.reader(inputFile, 'rb')
for row in reader:
    if row[5][6] == '':              ==>  (I mean select value the 5th row and 6th column)
        (do this)
    else:
        (do that)

Any help or guidance on this topic would be helpful -- I've done a similar task using lists; however, since the CSV file is raw, I don't know what to do.

Body:
My names.csv file.

number;first_name;last_name
1;Baked;Beans
2;Lovely;Spam
3;Wonderful;Spam
4;Up;Spam
5;Baked;Beans
6;Lovely;Spam
7;Wonderful;Spam
8;Down;Spam
9;Baked;Beans

My code in python

import csv
L = [0, 5, 7]

with open('names.csv',"r") as f:
    r = csv.DictReader(f, delimiter =";")
    for i, line in enumerate(r):
        if i in L:    # or (i+2) in L: from your second example
            print (line)
            print (line['first_name'], line['last_name'])


问:
How to assign values to checkboxes to particular number when they are checked
I have following checkboxes in my HTML page:-

```<code><label>ORDER TYPE - Today</label>
<div class="col-sm-12">
    <md-checkbox ng-model="obj.roles.order.today" class="md-primary md-hue-2 col-sm-1">Regular</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.today" class="margin-left md-primary md-hue-2 col-sm-2">Special Terms</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.today" class="md-primary md-hue-2 col-sm-1 no-right-padding">Stop</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.today" class="md-primary md-hue-2 col-sm-1">Odd</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.today" class="md-primary md-hue-2 col-sm-1">Limit</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.today" class="md-primary md-hue-2 col-sm-1">Auction</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.today" class="md-primary md-hue-2 col-sm-1">Call</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.today" class="margin-left md-primary md-hue-2 col-sm-2">Modification</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.today" class="md-primary md-hue-2 col-sm-2">Others</md-checkbox>
</div>
<label>VALIDITY TYPE - Today</label>
<div class="col-sm-12">
    <md-checkbox ng-model="obj.roles.validity.today" class="md-primary md-hue-2 col-sm-1">Pro</md-checkbox>
    <md-checkbox ng-model="obj.roles.validity.today" class="margin-left md-primary md-hue-2 col-sm-2">Client</md-checkbox>
    <md-checkbox ng-model="obj.roles.validity.today" class="md-primary md-hue-2 col-sm-1 no-right-padding">Participants</md-checkbox>
    <md-checkbox ng-model="obj.roles.validity.today" class="md-primary md-hue-2 col-sm-1">WHS</md-checkbox>
    <md-checkbox ng-model="obj.roles.validity.today" class="md-primary md-hue-2 col-sm-1">Buyback</md-checkbox>
    <md-checkbox ng-model="obj.roles.validity.today" class="margin-left md-primary md-hue-2 col-sm-2">SPLCLI</md-checkbox>
</div>
<label>CLIENT TYPE - Today</label>
<div class="col-sm-12">
    <md-checkbox ng-model="obj.roles.client.today" class="md-primary md-hue-2 col-sm-1">Day</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.today" class="margin-left md-primary md-hue-2 col-sm-2">IOC</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.today" class="md-primary md-hue-2 col-sm-1 no-right-padding">FOK</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.today" class="md-primary md-hue-2 col-sm-1">AON</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.today" class="md-primary md-hue-2 col-sm-1">GFS</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.today" class="md-primary md-hue-2 col-sm-1">GTC</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.today" class="md-primary md-hue-2 col-sm-1">GTD</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.today" class="margin-left md-primary md-hue-2 col-sm-2">MF</md-checkbox>
</div>

<label>ORDER TYPE - TOMMORROW</label>
<div class="col-sm-12">
    <md-checkbox ng-model="obj.roles.order.tommorrow" class="md-primary md-hue-2 col-sm-1">Regular</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.tommorrow" class="margin-left md-primary md-hue-2 col-sm-2">Special Terms</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.tommorrow" class="md-primary md-hue-2 col-sm-1 no-right-padding">Stop</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.tommorrow" class="md-primary md-hue-2 col-sm-1">Odd</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.tommorrow" class="md-primary md-hue-2 col-sm-1">Limit</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.tommorrow" class="md-primary md-hue-2 col-sm-1">Auction</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.tommorrow" class="md-primary md-hue-2 col-sm-1">Call</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.tommorrow" class="margin-left md-primary md-hue-2 col-sm-2">Modification</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.tommorrow" class="md-primary md-hue-2 col-sm-2">Others</md-checkbox>
</div>
<label>VALIDITY TYPE - TOMMORROW</label>
<div class="col-sm-12">
    <md-checkbox ng-model="obj.roles.validity.tommorrow" class="md-primary md-hue-2 col-sm-1">Pro</md-checkbox>
    <md-checkbox ng-model="obj.roles.validity.tommorrow" class="margin-left md-primary md-hue-2 col-sm-2">Client</md-checkbox>
    <md-checkbox ng-model="obj.roles.validity.tommorrow" class="md-primary md-hue-2 col-sm-1 no-right-padding">Participants</md-checkbox>
    <md-checkbox ng-model="obj.roles.validity.tommorrow" class="md-primary md-hue-2 col-sm-1">WHS</md-checkbox>
    <md-checkbox ng-model="obj.roles.validity.tommorrow" class="md-primary md-hue-2 col-sm-1">Buyback</md-checkbox>
    <md-checkbox ng-model="obj.roles.validity.tommorrow" class="md-primary md-hue-2 col-sm-1">Auction</md-checkbox>
    <md-checkbox ng-model="obj.roles.validity.tommorrow" class="md-primary md-hue-2 col-sm-1">Call</md-checkbox>
    <md-checkbox ng-model="obj.roles.validity.tommorrow" class="margin-left md-primary md-hue-2 col-sm-2">SPLCLI</md-checkbox>
</div>
<label>CLIENT TYPE - TOMMORROW</label>
<div class="col-sm-12">
    <md-checkbox ng-model="obj.roles.client.tommorrow" class="md-primary md-hue-2 col-sm-1">Day</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.tommorrow" class="margin-left md-primary md-hue-2 col-sm-2">IOC</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.tommorrow" class="md-primary md-hue-2 col-sm-1 no-right-padding">FOK</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.tommorrow" class="md-primary md-hue-2 col-sm-1">AON</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.tommorrow" class="md-primary md-hue-2 col-sm-1">GFS</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.tommorrow" class="md-primary md-hue-2 col-sm-1">GTC</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.tommorrow" class="md-primary md-hue-2 col-sm-1">GTD</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.tommorrow" class="margin-left md-primary md-hue-2 col-sm-2">MF</md-checkbox>
</div>
</code>```

In my directive code:-
I have predefined the array:-

```<code> scope.obj.roles = {
    "order" : {
        "today" : [],
        "tommorrow" : []
    },
    "validity" : {
        "today" : [],
        "tommorrow" : []
    },
    "client" : {
        "today" : [],
        "tommorrow" : []
    }
};
</code>```

Each checkbox is equal to a number. I want to push the associated numbers(which are predefined) in above arrays and store it in my backend:-

```<code>1 - Regular, 2 - Special Terms, 3 - Stop, 4 - Odd, 5 - Limit, 6 - Auction, 7 - Call, 8 - Modification, 9 - Others
1 - Pro, 2 - Client, 3 - Participants, 4 - WHS, 5 - Buyback, 6 - SPLCLI
1 - Day, 2 - IOC, 3 - FOK, 4 - AONIOC, 5 - GFS, 6 - GTC, 7 - GTD, 8 - MF
</code>```

How should I achieve that? So that whenever I check any checkbox only that checkbox number is pushed in array if unchecked it should be popped. If not checked then nothing should be pushed.

答:
```<code>We need a checked property for each array object, So I gave a sample
for your requirements.
<div ng-controller="MyCtrl">
<input type="checkbox" ng-model="current[0].checked" ng-
   checked="current[0].checked" />
<input type="checkbox" ng-model="current[1].checked" ng-
      checked="current[1].checked" />
<input type="checkbox" ng-model="current[2].checked" ng-
       checked="current[2].checked" />
   <button ng-click="save()">Click</button>
</div>
</code>```

Angular Code:

```<code>var myApp = angular.module('myApp',[]);
myApp.controller("MyCtrl", MyCtrl);
function MyCtrl($scope, $filte) {
    $scope.current = [{name: "Regular", status: false},
                      {name: "Shop", status: false},
                      {name: "Odd", status: false}];
    $scope.save = function() {
      var selectedArray =
          $filter('filter')($scope.current,
          function(val, key) {
            if(val.checked==true){
                return val;
            }
          }, true);
          console.log(selectedArray)
        }
     }
</code>```

Body:
I have following checkboxes in my HTML page:-

ORDER TYPE - Today

    <md-checkbox ng-model="obj.roles.order.today" class="md-primary md-hue-2 col-sm-1">Regular</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.today" class="margin-left md-primary md-hue-2 col-sm-2">Special Terms</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.today" class="md-primary md-hue-2 col-sm-1 no-right-padding">Stop</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.today" class="md-primary md-hue-2 col-sm-1">Odd</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.today" class="md-primary md-hue-2 col-sm-1">Limit</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.today" class="md-primary md-hue-2 col-sm-1">Auction</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.today" class="md-primary md-hue-2 col-sm-1">Call</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.today" class="margin-left md-primary md-hue-2 col-sm-2">Modification</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.today" class="md-primary md-hue-2 col-sm-2">Others</md-checkbox>

VALIDITY TYPE - Today

    <md-checkbox ng-model="obj.roles.validity.today" class="md-primary md-hue-2 col-sm-1">Pro</md-checkbox>
    <md-checkbox ng-model="obj.roles.validity.today" class="margin-left md-primary md-hue-2 col-sm-2">Client</md-checkbox>
    <md-checkbox ng-model="obj.roles.validity.today" class="md-primary md-hue-2 col-sm-1 no-right-padding">Participants</md-checkbox>
    <md-checkbox ng-model="obj.roles.validity.today" class="md-primary md-hue-2 col-sm-1">WHS</md-checkbox>
    <md-checkbox ng-model="obj.roles.validity.today" class="md-primary md-hue-2 col-sm-1">Buyback</md-checkbox>
    <md-checkbox ng-model="obj.roles.validity.today" class="margin-left md-primary md-hue-2 col-sm-2">SPLCLI</md-checkbox>

CLIENT TYPE - Today

    <md-checkbox ng-model="obj.roles.client.today" class="md-primary md-hue-2 col-sm-1">Day</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.today" class="margin-left md-primary md-hue-2 col-sm-2">IOC</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.today" class="md-primary md-hue-2 col-sm-1 no-right-padding">FOK</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.today" class="md-primary md-hue-2 col-sm-1">AON</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.today" class="md-primary md-hue-2 col-sm-1">GFS</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.today" class="md-primary md-hue-2 col-sm-1">GTC</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.today" class="md-primary md-hue-2 col-sm-1">GTD</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.today" class="margin-left md-primary md-hue-2 col-sm-2">MF</md-checkbox>

ORDER TYPE - TOMMORROW

    <md-checkbox ng-model="obj.roles.order.tommorrow" class="md-primary md-hue-2 col-sm-1">Regular</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.tommorrow" class="margin-left md-primary md-hue-2 col-sm-2">Special Terms</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.tommorrow" class="md-primary md-hue-2 col-sm-1 no-right-padding">Stop</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.tommorrow" class="md-primary md-hue-2 col-sm-1">Odd</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.tommorrow" class="md-primary md-hue-2 col-sm-1">Limit</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.tommorrow" class="md-primary md-hue-2 col-sm-1">Auction</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.tommorrow" class="md-primary md-hue-2 col-sm-1">Call</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.tommorrow" class="margin-left md-primary md-hue-2 col-sm-2">Modification</md-checkbox>
    <md-checkbox ng-model="obj.roles.order.tommorrow" class="md-primary md-hue-2 col-sm-2">Others</md-checkbox>

VALIDITY TYPE - TOMMORROW

    <md-checkbox ng-model="obj.roles.validity.tommorrow" class="md-primary md-hue-2 col-sm-1">Pro</md-checkbox>
    <md-checkbox ng-model="obj.roles.validity.tommorrow" class="margin-left md-primary md-hue-2 col-sm-2">Client</md-checkbox>
    <md-checkbox ng-model="obj.roles.validity.tommorrow" class="md-primary md-hue-2 col-sm-1 no-right-padding">Participants</md-checkbox>
    <md-checkbox ng-model="obj.roles.validity.tommorrow" class="md-primary md-hue-2 col-sm-1">WHS</md-checkbox>
    <md-checkbox ng-model="obj.roles.validity.tommorrow" class="md-primary md-hue-2 col-sm-1">Buyback</md-checkbox>
    <md-checkbox ng-model="obj.roles.validity.tommorrow" class="md-primary md-hue-2 col-sm-1">Auction</md-checkbox>
    <md-checkbox ng-model="obj.roles.validity.tommorrow" class="md-primary md-hue-2 col-sm-1">Call</md-checkbox>
    <md-checkbox ng-model="obj.roles.validity.tommorrow" class="margin-left md-primary md-hue-2 col-sm-2">SPLCLI</md-checkbox>

CLIENT TYPE - TOMMORROW

    <md-checkbox ng-model="obj.roles.client.tommorrow" class="md-primary md-hue-2 col-sm-1">Day</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.tommorrow" class="margin-left md-primary md-hue-2 col-sm-2">IOC</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.tommorrow" class="md-primary md-hue-2 col-sm-1 no-right-padding">FOK</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.tommorrow" class="md-primary md-hue-2 col-sm-1">AON</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.tommorrow" class="md-primary md-hue-2 col-sm-1">GFS</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.tommorrow" class="md-primary md-hue-2 col-sm-1">GTC</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.tommorrow" class="md-primary md-hue-2 col-sm-1">GTD</md-checkbox>
    <md-checkbox ng-model="obj.roles.client.tommorrow" class="margin-left md-primary md-hue-2 col-sm-2">MF</md-checkbox>

In my directive code:-
I have predefined the array:-

 scope.obj.roles = {
    "order" : {
        "today" : [],
        "tommorrow" : []
    },
    "validity" : {
        "today" : [],
        "tommorrow" : []
    },
    "client" : {
        "today" : [],
        "tommorrow" : []
    }
};

Each checkbox is equal to a number. I want to push the associated numbers(which are predefined) in above arrays and store it in my backend:-

1 - Regular, 2 - Special Terms, 3 - Stop, 4 - Odd, 5 - Limit, 6 - Auction, 7 - Call, 8 - Modification, 9 - Others
1 - Pro, 2 - Client, 3 - Participants, 4 - WHS, 5 - Buyback, 6 - SPLCLI
1 - Day, 2 - IOC, 3 - FOK, 4 - AONIOC, 5 - GFS, 6 - GTC, 7 - GTD, 8 - MF

How should I achieve that? So that whenever I check any checkbox only that checkbox number is pushed in array if unchecked it should be popped. If not checked then nothing should be pushed.

Body:
We need a checked property for each array object, So I gave a sample
for your requirements.
<div ng-controller="MyCtrl">
<input type="checkbox" ng-model="current[0].checked" ng-
   checked="current[0].checked" />
<input type="checkbox" ng-model="current[1].checked" ng-
      checked="current[1].checked" />
<input type="checkbox" ng-model="current[2].checked" ng-
       checked="current[2].checked" />
   <button ng-click="save()">Click</button>
</div>

Angular Code:

var myApp = angular.module('myApp',[]);
myApp.controller("MyCtrl", MyCtrl);
function MyCtrl($scope, $filte) {
    $scope.current = [{name: "Regular", status: false},
                      {name: "Shop", status: false},
                      {name: "Odd", status: false}];
    $scope.save = function() {
      var selectedArray =
          $filter('filter')($scope.current,
          function(val, key) {
            if(val.checked==true){
                return val;
            }
          }, true);
          console.log(selectedArray)
        }
     }


问:
VB Send Email in Table
i need help in sending table in email after retrieving from database. Managed to retrieve the data but the table on show one row but the database have many rows.

The problem of the code is around Message.Body += sb.ToString. All the code above is working perfectly during debug.

I couldnt solve the problem. please help!

```<code>Imports System.Data.SqlClient
Imports System.Data
Imports System.Net.Mail
Imports System.Text

Module Module1
    Dim db As New Database

    Sub Main()

        Dim Message As MailMessage = New MailMessage()
        Dim Smtp As New SmtpClient()

        Dim emailTo As String = "email@email.com"
        Smtp.UseDefaultCredentials = True
        Smtp.Host = "server.com"
        Smtp.Port = 25

        Message.Subject = "Computers"
        Message.To.Add("email@email.com")
        Message.IsBodyHtml = True
        Message.Priority = MailPriority.High
        Message.From = New MailAddress("email@email.com")

        Dim sql As String
        Dim sql1 As String
        Dim dr As SqlDataReader
        Dim dr1 As SqlDataReader

        Dim count As Integer = 0

        Dim connstring As String = ("Server=QSD13\SQLEXPRESS; Initial Catalog = SoftwareManagementV2; UID=sa; Pwd=password;")
        Dim connection As New SqlConnection(connstring)

        db.OpenConn()

        'Select version and affected softwarename from both SCCM1 DB and affectedsoftware DB to check which are the affected computers
        sql = "SELECT SCCM1.DisplayName00, SCCM1.Version00, AffectedSoftware.Version00, AffectedSoftware.DisplayName00, SCCM1.Name00, SCCM1.InstallDate00, SCCM1.Publisher00, SCCM1.LastHWScan, SCCM1.DisplayName, SCCM1.email, SCCM1.Division, SCCM1.Dept, SCCM1.Brand, SCCM1.Model, SCCM1.OS from [SoftwareManagementV2].[dbo].AffectedSoftware, [CM_P01].[dbo].SCCM1 WHERE SCCM1.DisplayName00 = AffectedSoftware.DisplayName00 AND SCCM1.Version00 = AffectedSoftware.Version00"
        dr = db.ExecuteQuery(sql)

        'Select only values that appear once
        sql1 = "Select DISTINCT Name00, DisplayName00, Version00 FROM [SoftwareManagementV2].[dbo].[AffectedComputer] group by Name00, DisplayName00, Version00"
        dr1 = db.ExecuteQuery(sql1)

        'both condition must be satisfied to insert in affected computer db
        While dr.Read = True

            'Prevent duplicate values inserted into affected computer db
            If dr1.Read = False Then
                Console.WriteLine("Display Name:" + dr(0) + ", Version:" + dr(1) + ", Computer Name:" + dr(4))

                Dim cmd As SqlCommand = connection.CreateCommand
                connection.Open()

                'Insert affected computers and softwarenames into AffectedComputer DB
                cmd.CommandText = "INSERT into AffectedComputer(Name00, DisplayName00, InstallDate00, Publisher00, Version00, LastHWScan, DisplayName, email, Division, Dept, Brand, Model, OS) VALUES (@Name00, @DisplayName00, @InstallDate00, @Publisher00, @Version00, @LastHWScan, @DisplayName, @email, @Division, @Dept, @Brand, @Model, @OS)"
                cmd.Parameters.AddWithValue("@Name00", dr(4))
                cmd.Parameters.AddWithValue("@DisplayName00", dr(0))
                cmd.Parameters.AddWithValue("@InstallDate00", dr(5))
                cmd.Parameters.AddWithValue("@Publisher00", dr(6))
                cmd.Parameters.AddWithValue("@Version00", dr(1))
                cmd.Parameters.AddWithValue("@LastHWScan", dr(7))
                cmd.Parameters.AddWithValue("@DisplayName", dr(8))
                cmd.Parameters.AddWithValue("@email", dr(9))
                cmd.Parameters.AddWithValue("@Division", dr(10))
                cmd.Parameters.AddWithValue("@Dept", dr(11))
                cmd.Parameters.AddWithValue("@Brand", dr(12))
                cmd.Parameters.AddWithValue("@Model", dr(13))
                cmd.Parameters.AddWithValue("@OS", dr(14))
                cmd.ExecuteNonQuery()
                connection.Close()

                Dim collection As New Collection
                Dim item1, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11, item12, item13 As String

                item1 = dr(4)
                item2 = dr(0)
                item3 = dr(5)
                item4 = dr(6)
                item5 = dr(1)
                item6 = dr(7)
                item7 = dr(8)
                item8 = dr(9)
                item9 = dr(10)
                item10 = dr(11)
                item11 = dr(12)
                item12 = dr(13)
                item13 = dr(14)
                Dim all = item1.ToString + item2.ToString + item3.ToString + item4.ToString + item5.ToString + item6.ToString + item7.ToString + item8.ToString + item9.ToString + item10.ToString + item11.ToString + item12.ToString + item13.ToString
                collection.Add(all)

                Dim sb As New StringBuilder

                sb.Append("<html><table  border=""1"" cellpadding=""0"" cellspacing=""0"" bordercolor=""000000"" align=""center"">")
                sb.Append("<tr>")
                sb.Append("<th bordercolor=""#000000"" bgcolor=""#FFFF00"" scope=""col"">Name00</th>")
                sb.Append("<th bordercolor=""#000000"" bgcolor=""#FFFF00"" scope=""col"">DisplayName00</th>")
                sb.Append("<th bordercolor=""#000000"" bgcolor=""#FFFF00"" scope=""col"">InstallDate00</th>")
                sb.Append("<th bordercolor=""#000000"" bgcolor=""#FFFF00"" scope=""col"">Publisher00</th>")
                sb.Append("<th bordercolor=""#000000"" bgcolor=""#FFFF00"" scope=""col"">Version00</th>")
                sb.Append("<th bordercolor=""#000000"" bgcolor=""#FFFF00"" scope=""col"">LastHWScan</th>")
                sb.Append("<th bordercolor=""#000000"" bgcolor=""#FFFF00"" scope=""col"">Display Name</th>")
                sb.Append("<th bordercolor=""#000000"" bgcolor=""#FFFF00"" scope=""col"">email</th>")
                sb.Append("<th bordercolor=""#000000"" bgcolor=""#FFFF00"" scope=""col"">Divison</th>")
                sb.Append("<th bordercolor=""#000000"" bgcolor=""#FFFF00"" scope=""col"">Dept</th>")
                sb.Append("<th bordercolor=""#000000"" bgcolor=""#FFFF00"" scope=""col"">Brand</th>")
                sb.Append("<th bordercolor=""#000000"" bgcolor=""#FFFF00"" scope=""col"">Model</th>")
                sb.Append("<th bordercolor=""#000000"" bgcolor=""#FFFF00"" scope=""col"">OS</th>")
                sb.Append("</tr>")

                For Each all In collection
                    sb.Append("<tr>")
                    sb.Append("<td bordercolor=""#000000"">" + item1 + "</td>")
                    sb.Append("<td bordercolor=""#000000"">" + item2 + "</td>")
                    sb.Append("<td bordercolor=""#000000"">" + item3 + "</td>")
                    sb.Append("<td bordercolor=""#000000"">" + item4 + "</td>")
                    sb.Append("<td bordercolor=""#000000"">" + item5 + "</td>")
                    sb.Append("<td bordercolor=""#000000"">" + item6 + "</td>")
                    sb.Append("<td bordercolor=""#000000"">" + item7 + "</td>")
                    sb.Append("<td bordercolor=""#000000"">" + item8 + "</td>")
                    sb.Append("<td bordercolor=""#000000"">" + item9 + "</td>")
                    sb.Append("<td bordercolor=""#000000"">" + item10 + "</td>")
                    sb.Append("<td bordercolor=""#000000"">" + item11 + "</td>")
                    sb.Append("<td bordercolor=""#000000"">" + item12 + "</td>")
                    sb.Append("<td bordercolor=""#000000"">" + item13 + "</td>")
                    sb.Append("</tr>")
                Next

                sb.Append("</table>")
                sb.Append("</br></html>")

                Message.Body += sb.ToString

                count = + 1

            End If

        End While

        dr.Close()
        dr1.Close()
        db.CloseConn()

        'Only send email when theres row(s)
        If count > 0 Then
            Smtp.Send(Message)
        End If

    End Sub

End Module
</code>```

答:
Your collection variable contains 1 string per row. So your table builder should be:</p>

```<code>For Each all In collection
                sb.Append("<tr>")
                sb.Append("<td bordercolor=""#000000"">" + all + "</td>")
                sb.Append("</tr>")
            Next
</code>```

Title: VB Send Email in Table

Body:
i need help in sending table in email after retrieving from database. Managed to retrieve the data but the table on show one row but the database have many rows.

The problem of the code is around Message.Body += sb.ToString. All the code above is working perfectly during debug.

I couldnt solve the problem. please help!

Imports System.Data.SqlClient
Imports System.Data
Imports System.Net.Mail
Imports System.Text

Module Module1
    Dim db As New Database

    Sub Main()

        Dim Message As MailMessage = New MailMessage()
        Dim Smtp As New SmtpClient()

        Dim emailTo As String = "email@email.com"
        Smtp.UseDefaultCredentials = True
        Smtp.Host = "server.com"
        Smtp.Port = 25

        Message.Subject = "Computers"
        Message.To.Add("email@email.com")
        Message.IsBodyHtml = True
        Message.Priority = MailPriority.High
        Message.From = New MailAddress("email@email.com")

        Dim sql As String
        Dim sql1 As String
        Dim dr As SqlDataReader
        Dim dr1 As SqlDataReader

        Dim count As Integer = 0

        Dim connstring As String = ("Server=QSD13\SQLEXPRESS; Initial Catalog = SoftwareManagementV2; UID=sa; Pwd=password;")
        Dim connection As New SqlConnection(connstring)

        db.OpenConn()

        'Select version and affected softwarename from both SCCM1 DB and affectedsoftware DB to check which are the affected computers
        sql = "SELECT SCCM1.DisplayName00, SCCM1.Version00, AffectedSoftware.Version00, AffectedSoftware.DisplayName00, SCCM1.Name00, SCCM1.InstallDate00, SCCM1.Publisher00, SCCM1.LastHWScan, SCCM1.DisplayName, SCCM1.email, SCCM1.Division, SCCM1.Dept, SCCM1.Brand, SCCM1.Model, SCCM1.OS from [SoftwareManagementV2].[dbo].AffectedSoftware, [CM_P01].[dbo].SCCM1 WHERE SCCM1.DisplayName00 = AffectedSoftware.DisplayName00 AND SCCM1.Version00 = AffectedSoftware.Version00"
        dr = db.ExecuteQuery(sql)

        'Select only values that appear once
        sql1 = "Select DISTINCT Name00, DisplayName00, Version00 FROM [SoftwareManagementV2].[dbo].[AffectedComputer] group by Name00, DisplayName00, Version00"
        dr1 = db.ExecuteQuery(sql1)

        'both condition must be satisfied to insert in affected computer db
        While dr.Read = True

            'Prevent duplicate values inserted into affected computer db
            If dr1.Read = False Then
                Console.WriteLine("Display Name:" + dr(0) + ", Version:" + dr(1) + ", Computer Name:" + dr(4))

                Dim cmd As SqlCommand = connection.CreateCommand
                connection.Open()

                'Insert affected computers and softwarenames into AffectedComputer DB
                cmd.CommandText = "INSERT into AffectedComputer(Name00, DisplayName00, InstallDate00, Publisher00, Version00, LastHWScan, DisplayName, email, Division, Dept, Brand, Model, OS) VALUES (@Name00, @DisplayName00, @InstallDate00, @Publisher00, @Version00, @LastHWScan, @DisplayName, @email, @Division, @Dept, @Brand, @Model, @OS)"
                cmd.Parameters.AddWithValue("@Name00", dr(4))
                cmd.Parameters.AddWithValue("@DisplayName00", dr(0))
                cmd.Parameters.AddWithValue("@InstallDate00", dr(5))
                cmd.Parameters.AddWithValue("@Publisher00", dr(6))
                cmd.Parameters.AddWithValue("@Version00", dr(1))
                cmd.Parameters.AddWithValue("@LastHWScan", dr(7))
                cmd.Parameters.AddWithValue("@DisplayName", dr(8))
                cmd.Parameters.AddWithValue("@email", dr(9))
                cmd.Parameters.AddWithValue("@Division", dr(10))
                cmd.Parameters.AddWithValue("@Dept", dr(11))
                cmd.Parameters.AddWithValue("@Brand", dr(12))
                cmd.Parameters.AddWithValue("@Model", dr(13))
                cmd.Parameters.AddWithValue("@OS", dr(14))
                cmd.ExecuteNonQuery()
                connection.Close()

                Dim collection As New Collection
                Dim item1, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11, item12, item13 As String

                item1 = dr(4)
                item2 = dr(0)
                item3 = dr(5)
                item4 = dr(6)
                item5 = dr(1)
                item6 = dr(7)
                item7 = dr(8)
                item8 = dr(9)
                item9 = dr(10)
                item10 = dr(11)
                item11 = dr(12)
                item12 = dr(13)
                item13 = dr(14)
                Dim all = item1.ToString + item2.ToString + item3.ToString + item4.ToString + item5.ToString + item6.ToString + item7.ToString + item8.ToString + item9.ToString + item10.ToString + item11.ToString + item12.ToString + item13.ToString
                collection.Add(all)

                Dim sb As New StringBuilder

                sb.Append("
")
                sb.Append("
")
                sb.Append("Name00	")
                sb.Append("DisplayName00	")
                sb.Append("InstallDate00	")
                sb.Append("Publisher00	")
                sb.Append("Version00	")
                sb.Append("LastHWScan	")
                sb.Append("Display Name	")
                sb.Append("email	")
                sb.Append("Divison	")
                sb.Append("Dept	")
                sb.Append("Brand	")
                sb.Append("Model	")
                sb.Append("OS	")
                sb.Append("
")

                For Each all In collection
                    sb.Append("
")
                    sb.Append("" + item1 + "	")
                    sb.Append("" + item2 + "	")
                    sb.Append("" + item3 + "	")
                    sb.Append("" + item4 + "	")
                    sb.Append("" + item5 + "	")
                    sb.Append("" + item6 + "	")
                    sb.Append("" + item7 + "	")
                    sb.Append("" + item8 + "	")
                    sb.Append("" + item9 + "	")
                    sb.Append("" + item10 + "	")
                    sb.Append("" + item11 + "	")
                    sb.Append("" + item12 + "	")
                    sb.Append("" + item13 + "	")
                    sb.Append("
")
                Next

                sb.Append("
")
                sb.Append("
")

                Message.Body += sb.ToString

                count = + 1

            End If

        End While

        dr.Close()
        dr1.Close()
        db.CloseConn()

        'Only send email when theres row(s)
        If count > 0 Then
            Smtp.Send(Message)
        End If

    End Sub

End Module

Body:
Your collection variable contains 1 string per row. So your table builder should be:

For Each all In collection
                sb.Append("<tr>")
                sb.Append("<td bordercolor=""#000000"">" + all + "</td>")
                sb.Append("</tr>")
            Next


问:
java swing jtable add two table from database in single table
I have table named  tbl_income and tbl_expenses...
tbl_income contain four column and four row and tbl_expenses contain four column and three row link in picture below.

I want to mank single table in java swing JTable link picture in below.

how can i make like this.... sorry for bad english..

This is what i've tried:

```<code> DefaultTableModel model = (DefaultTableModel) tbldailybook.getModel();
        try {
            Statement stmt = db.cn.createStatement();
            ResultSet rs = stmt.executeQuery("select * from tblincome,tblexpenses");
            while (rs.next()) {
                model.addRow(new Object[]{rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(6), rs.getString(7), rs.getString(8)});
            }
        } catch (Exception e) {
        }
</code>```

tblincome have single row but row reply

答:
This is a solution with separate extraction of the two tables and their integration into a common TableModel.

```<code>public class MyTableModel extends AbstractTableModel implements TableModel {
    private List<Data> inclomeList;
    private List<Data> expenseList;

    private void setData(List<Data> list, Data data) {
        int rows = getRowCount();
        int row = list.size();
        list.add(data);

        if(row < rows) {
            fireTableRowsUpdated(row, row);
        }
        else {
            fireTableRowsInserted(row, row);
        }
    }

    public void setIncomeData(Data data) {
        if(inclomeList == null) {
            inclomeList = new ArrayList<>();
        }

        setData(inclomeList, data);
    }

    public void setExpenseData(Data data) {
        if(expenseList == null) {
            expenseList = new ArrayList<>();
        }

        setData(expenseList, data);
    }

    @Override
    public String getColumnName(int column) {
        switch (column) {
            case 0:
            case 3:
                return "Date";

            case 1: return "Income";
            case 4: return "Expenses";

            case 2:
            case 5:
                return "Amount";

            default:
                return super.getColumnName(column);
        }
    }

    @Override
    public int getRowCount() {
        if(inclomeList == null || expenseList == null) {
            if(inclomeList != null) {
                return inclomeList.size();
            }
            else if(expenseList != null) {
                return expenseList.size();
            }

            return 0;
        }

        return Math.max(inclomeList.size(), expenseList.size());
    }

    @Override
    public int getColumnCount() {
        return 6;
    }

    @Override
    public Object getValueAt(int row, int column) {
        Data inclome = null;
        Data expense = null;

        if(inclomeList != null && inclomeList.size() > row) {
            inclome = inclomeList.get(row);
        }

        if(expenseList != null && expenseList.size() > row) {
            expense = expenseList.get(row);
        }

        switch (column) {
            case 0: return inclome != null ? inclome.getDate() : "";
            case 1: return inclome != null ? inclome.getName() : "";
            case 2: return inclome != null ? inclome.getAmount() : "";
            case 3: return expense != null ? expense.getDate() : "";
            case 4: return expense != null ? expense.getName() : "";
            case 5: return expense != null ? expense.getAmount() : "";
        }

        return null;
    }

    public void update() {
        SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
            @Override
            protected Void doInBackground() throws Exception {
                Database database = new Database();
                inclomeList = database.getData(Database.TBL_INCOME);
                expenseList = database.getData(Database.TBL_EXPENSES);

                return null;
            }

            @Override
            protected void done() {
                try {
                    get();
                    fireTableDataChanged();
                }
                catch (InterruptedException | ExecutionException e) {
                    e.printStackTrace();
                }
            }
        };

        worker.execute();
    }
}
</code>```

Interface for working with the database:

```<code>public class Database {
    public static final String TBL_INCOME = "tbl_income";
    public static final String TBL_EXPENSES = "tbl_expenses";

    private Connection getConnection() throws SQLException {
        return DriverManager.getConnection("jdbc:mysql://192.168.40.5/test", "root", "");
    }

    public List<Data> getData(String tbl_name) throws SQLException {
        try (Connection connection = getConnection()) {
            String query = "select * from " + tbl_name;

            try(ResultSet rs = connection.createStatement().executeQuery(query)) {
                List<Data> list = new ArrayList<>();
                while (rs.next()) {
                    Data data = new Data();
                    data.setDate(rs.getDate("date"));
                    data.setName(rs.getString("particular"));
                    data.setAmount(rs.getDouble("amount"));

                    list.add(data);
                }

                return list;
            }
        }
    }
}
</code>```

MainFrame.java

```<code>public class MainFrame extends JFrame {

    private JTable table = new JTable(new MyTableModel());

    public MainFrame() throws HeadlessException {
        super("MainFrame");
        createGUI();
    }

    private void createGUI() {
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        setPreferredSize(new Dimension(600, 400));

        JButton addI = new JButton("+");
        addI.addActionListener(e -> ((MyTableModel)table.getModel()).setIncomeData(new Data()));

        JButton addE = new JButton("+");
        addE.addActionListener(e -> ((MyTableModel)table.getModel()).setExpenseData(new Data()));

        JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0));
        panel.add(addI);
        panel.add(addE);

        JScrollPane scrollPane = new JScrollPane(table);
        add(scrollPane, BorderLayout.CENTER);
        add(panel, BorderLayout.PAGE_END);

        pack();
        setLocationRelativeTo(null);

        ((MyTableModel)table.getModel()).update();
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> new MainFrame().setVisible(true));
    }
}
</code>```

Body:
I have table named  tbl_income and tbl_expenses...
tbl_income contain four column and four row and tbl_expenses contain four column and three row link in picture below.

I want to mank single table in java swing JTable link picture in below.

how can i make like this.... sorry for bad english..

This is what i've tried:

 DefaultTableModel model = (DefaultTableModel) tbldailybook.getModel();
        try {
            Statement stmt = db.cn.createStatement();
            ResultSet rs = stmt.executeQuery("select * from tblincome,tblexpenses");
            while (rs.next()) {
                model.addRow(new Object[]{rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(6), rs.getString(7), rs.getString(8)});
            }
        } catch (Exception e) {
        }

tblincome have single row but row reply

Body:
This is a solution with separate extraction of the two tables and their integration into a common TableModel.

public class MyTableModel extends AbstractTableModel implements TableModel {
    private List<Data> inclomeList;
    private List<Data> expenseList;

    private void setData(List<Data> list, Data data) {
        int rows = getRowCount();
        int row = list.size();
        list.add(data);

        if(row < rows) {
            fireTableRowsUpdated(row, row);
        }
        else {
            fireTableRowsInserted(row, row);
        }
    }

    public void setIncomeData(Data data) {
        if(inclomeList == null) {
            inclomeList = new ArrayList<>();
        }

        setData(inclomeList, data);
    }

    public void setExpenseData(Data data) {
        if(expenseList == null) {
            expenseList = new ArrayList<>();
        }

        setData(expenseList, data);
    }

    @Override
    public String getColumnName(int column) {
        switch (column) {
            case 0:
            case 3:
                return "Date";

            case 1: return "Income";
            case 4: return "Expenses";

            case 2:
            case 5:
                return "Amount";

            default:
                return super.getColumnName(column);
        }
    }

    @Override
    public int getRowCount() {
        if(inclomeList == null || expenseList == null) {
            if(inclomeList != null) {
                return inclomeList.size();
            }
            else if(expenseList != null) {
                return expenseList.size();
            }

            return 0;
        }

        return Math.max(inclomeList.size(), expenseList.size());
    }

    @Override
    public int getColumnCount() {
        return 6;
    }

    @Override
    public Object getValueAt(int row, int column) {
        Data inclome = null;
        Data expense = null;

        if(inclomeList != null && inclomeList.size() > row) {
            inclome = inclomeList.get(row);
        }

        if(expenseList != null && expenseList.size() > row) {
            expense = expenseList.get(row);
        }

        switch (column) {
            case 0: return inclome != null ? inclome.getDate() : "";
            case 1: return inclome != null ? inclome.getName() : "";
            case 2: return inclome != null ? inclome.getAmount() : "";
            case 3: return expense != null ? expense.getDate() : "";
            case 4: return expense != null ? expense.getName() : "";
            case 5: return expense != null ? expense.getAmount() : "";
        }

        return null;
    }

    public void update() {
        SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
            @Override
            protected Void doInBackground() throws Exception {
                Database database = new Database();
                inclomeList = database.getData(Database.TBL_INCOME);
                expenseList = database.getData(Database.TBL_EXPENSES);

                return null;
            }

            @Override
            protected void done() {
                try {
                    get();
                    fireTableDataChanged();
                }
                catch (InterruptedException | ExecutionException e) {
                    e.printStackTrace();
                }
            }
        };

        worker.execute();
    }
}

Interface for working with the database:

public class Database {
    public static final String TBL_INCOME = "tbl_income";
    public static final String TBL_EXPENSES = "tbl_expenses";

    private Connection getConnection() throws SQLException {
        return DriverManager.getConnection("jdbc:mysql://192.168.40.5/test", "root", "");
    }

    public List<Data> getData(String tbl_name) throws SQLException {
        try (Connection connection = getConnection()) {
            String query = "select * from " + tbl_name;

            try(ResultSet rs = connection.createStatement().executeQuery(query)) {
                List<Data> list = new ArrayList<>();
                while (rs.next()) {
                    Data data = new Data();
                    data.setDate(rs.getDate("date"));
                    data.setName(rs.getString("particular"));
                    data.setAmount(rs.getDouble("amount"));

                    list.add(data);
                }

                return list;
            }
        }
    }
}

MainFrame.java

public class MainFrame extends JFrame {

    private JTable table = new JTable(new MyTableModel());

    public MainFrame() throws HeadlessException {
        super("MainFrame");
        createGUI();
    }

    private void createGUI() {
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        setPreferredSize(new Dimension(600, 400));

        JButton addI = new JButton("+");
        addI.addActionListener(e -> ((MyTableModel)table.getModel()).setIncomeData(new Data()));

        JButton addE = new JButton("+");
        addE.addActionListener(e -> ((MyTableModel)table.getModel()).setExpenseData(new Data()));

        JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0));
        panel.add(addI);
        panel.add(addE);

        JScrollPane scrollPane = new JScrollPane(table);
        add(scrollPane, BorderLayout.CENTER);
        add(panel, BorderLayout.PAGE_END);

        pack();
        setLocationRelativeTo(null);

        ((MyTableModel)table.getModel()).update();
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> new MainFrame().setVisible(true));
    }
}


问:
How can I calculate a point between two given points in processing?
I have two given coordinates, for example (20,30) and (90,40). How can I find out a point on the line between these two points?

I need to do this in processing but also a general mathematical solution would help me.

答:
Java doesnt have lerp so here it is how it works in general</p>

```<code>float lerp(float point1, float point2, float dist) {
    return point1 + dist * (point2 - point1);
}
</code>```

Body:
Java doesnt have lerp so here it is how it works in general

float lerp(float point1, float point2, float dist) {
    return point1 + dist * (point2 - point1);
}

ContentLicense: CC BY-SA 4.0


问:
Eclipse SCSS Highlighting doesn't work for "//" comments
Eclipse seems to be missing highlighting for // comments in SCSS:

Is there a way I can add that?

I added *.scss files to follow the highlighting of *.css files, but the reason why I'm running into this problem is that // comments are not allowed in CSS but they are in SCSS.

```<code>//This line is not properly highlighted
/*This line is properly highlighted*/
</code>```

答:
The Eclipse Web Tools Platform CSS editor does not support SCSS.

You can use the LiClipseText plug-in to edit SCSS files.

See Eclipse Marketplace for plug-ins that support SCSS.

Body:
Eclipse seems to be missing highlighting for // comments in SCSS:

Is there a way I can add that?

I added *.scss files to follow the highlighting of *.css files, but the reason why I'm running into this problem is that // comments are not allowed in CSS but they are in SCSS.

//This line is not properly highlighted
/*This line is properly highlighted*/


问:
XMLHttprequest Error message even in case of success
This "working" script sends JSON to an external API. What it won't do correctly is log success or error in the console.
Even if it works, it still displays me "Error" three times.
Questions:

a. Where is the error in the code that causes the error message in case of success?

Edit: This part (a) has been answered by Suren Srapyan, I had the abc.status messed up, code below has been updated

b. Does de XMLHttpRequest() allways run three times and therefore log the message thrice or is this caused by something else?

Edit: This is most likely caused by an other part of the code

```<code>var abc = new XMLHttpRequest();
  var url = "http://myurl";
  abc.open("POST", url, true);
  abc.setRequestHeader("Content-type","application/json");
  abc.onreadystatechange = function () {
    if (abc.status >= 200 && abc.status < 300) {
        console.log(abc.responseText);
        console.log("Success!!");
    } else {
      console.log("Error!");
    }
</code>```

答:
A value can not be >= 200 and less than 200 at the same time. So you will always get the Error message. I think you need to check the statusCode only compare with 200. But also be aware that you get the status. If you are going into cross site you will get status code set to 0.

var abc = new XMLHttpRequest();
var url = 'https://jsonplaceholder.typicode.com/posts/1';

abc.onreadystatechange = function () {
  console.log(abc.status);
  if (abc.status === 200) {
      console.log(abc.responseText);
      console.log("Success!!");
  } else {
    console.log("Error!");
  }
}

abc.open("GET", url, true);
abc.setRequestHeader("Content-type","application/json");```

Body:
This "working" script sends JSON to an external API. What it won't do correctly is log success or error in the console.
Even if it works, it still displays me "Error" three times.
Questions:

a. Where is the error in the code that causes the error message in case of success?

Edit: This part (a) has been answered by Suren Srapyan, I had the abc.status messed up, code below has been updated

b. Does de XMLHttpRequest() allways run three times and therefore log the message thrice or is this caused by something else?

Edit: This is most likely caused by an other part of the code

var abc = new XMLHttpRequest();
  var url = "http://myurl";
  abc.open("POST", url, true);
  abc.setRequestHeader("Content-type","application/json");
  abc.onreadystatechange = function () {
    if (abc.status >= 200 && abc.status < 300) {
        console.log(abc.responseText);
        console.log("Success!!");
    } else {
      console.log("Error!");
    }


问:
How do I open a new window/tab and dynamically fill it with content?
I am building a website that displays recipes. Each recipe appears as part of a blog entry, and will have a link at the bottom to Print this recipe.

What I want to happen is a click on the link opens a new window and fills it with a print-friendly-styled version of the recipe, which is already inside its own
.

Can I do this with JS/jQuery alone, or do I need to process from the server side? Any ideas how to do this?

EDIT: What would be ideal would be to generate a PDF on the fly, but in lieu of that I'd like a new window, containing only the recipe, for the visitor to print out or save, as they see fit. Print-styles are nice, but most people don't know they exist and can't be bothered to check and see by printing out a page that doesn't look print ready.

答: You can do this simply with CSS alone if you have it load the exact same page but with a different stylesheet.</p>

ContentLicense: CC BY-SA 2.5


问:
Elasticsearch not getting enough file descriptors
Elasticsearch is failing because of the following bootstrap error.

max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

I have set the value as root using sysctl and ulimit commands and verified using cat /proc/sys/fs/file-max. Yet, the elasticsearch process does not get more than 4096 file descriptors. I even tried to start a new session from the root session I created but no luck there. What else could be the problem?

答:
For the .zip and .tar.gz packages, set ulimit -n 65536 as root before starting Elasticsearch, or set nofile to 65536 in /etc/security/limits.conf.

Please find the full reference here.


问:
SSIS Join Recordset With Table
I have an SSIS package in which I'm reading the records from a Flat File and storing them in a recordset. Is it possible to compare the values in the recordset with the values in a database table and update the table?

I'm Using SQL Server 2008 R2 and Same version of SSIS.

答:
Leran2002's answer in general is right, the most straight forward way is to have a lookup component set up to Redirect rows to no match output and use a destination and a OLE DB Command afterwards.

However depending on the size of the result sets, this might be slow, since the lookup component will check each row one-by-one and if your destination table has lots of records, this will take some time. Furthermore, depending on your cache settings in the lookup component, it can use lots of memory.

There are two more ways to achieve this:

Merge Join

Using your file source and your destination table as a source, you can use a Merge Join. The logic in the DFT is a bit more complex, but this more a set-based approach and with large result sets it is working better.

You'll have to implement the logic which record has to be updated, inserted, deleted or discarded from the file using a conditional split component.

I highly recommend this question (not exactly your problem, but a good comparison in my opinion): What are the differences between Merge Join and Lookup transformations in SSIS?

Staging table

Another way is to use a staging table to temporarily store the records from a file. In this case, your DFT just loads the records from a file into the staging table, then with one or more Execute SQL Task you can do the merging of the two data sets. (UPDATE, INSERT, DELETE, MERGE, you can use what fits your needs).

Title: SSIS Join Recordset With Table


问:
how to get element of list without string
I have a list like:

```<code>my_list = ['[:,y+1,x+1]', '[:,y+1,x-1]']
my_list[0]
</code>```

gives:

```<code>'[:,y+1,x+1]'
</code>```

How to get only

```<code>[:,y+1,x+1]
</code>```

Why I need this: I am trying to read netcdf file with the with the coordinates from the list, something like:

```<code>from netCDF4 import Dataset
fd = Dataset(ncfile,'r')
fd.variables['t2m']my_list[0]
</code>```

where x and y are predefined.

答:
It looks to me as if you are looking for np.s_ which allows you to 'freeze' indexing expressions. Try

```<code>my_list = [np.s_[:,y+1,x+1], np.s_[:,y+1,x-1]]
</code>```

Body:
I have a list like:

my_list = ['[:,y+1,x+1]', '[:,y+1,x-1]']
my_list[0]

gives:

'[:,y+1,x+1]'

How to get only

[:,y+1,x+1]

Why I need this: I am trying to read netcdf file with the with the coordinates from the list, something like:

from netCDF4 import Dataset
fd = Dataset(ncfile,'r')
fd.variables['t2m']my_list[0]

where x and y are predefined.

Body:
It looks to me as if you are looking for np.s_ which allows you to 'freeze' indexing expressions. Try

my_list = [np.s_[:,y+1,x+1], np.s_[:,y+1,x-1]]


问:
Struggling to persist a reference to table cells during a suite run
I am attempting to read out values from table cells on a row for checking values match as expected.

I am facing a situation where protractor is unable to get the text of particular cells I am interested in as it cannot find the cells I am querying.

Here is my test suite steps:

```<code>beforeAll(function() {
    common.journeyValidationBtn.click();
    helper.waitForUrlToContain('journey-validation');
    helper.waitForElementToHide(common.spinner);
    common.fabBtn.click();
    helper.waitForPresenceOf(common.calculateBtn);
    common.runCalculation(secondaryPeriod);
    helper.waitForPresenceOf(common.fabBtn, 30000);
    helper.waitForElementToHide(common.spinner);
    common.selectComparisonPeriod(initialPeriod);
    helper.waitForTableRows(page.reimbursementCalculations).then(function() {
        console.log('*** Table Rows Found - promise resolved ***');
        page.reimbursementCalculations.count().then(function(count){
            console.log('*** Number of Table Rows Found - ' + count + ' ***');
            row = page.reimbursementCalculations.first();
            cells = row.all(by.css('td'));
            cells.count().then(function(cellCount){
                console.log('*** Number of Table Cells Found - ' + cellCount + ' ***');
                cells.get(0).getText().then(function(text){
                    console.log('*** First Table Cell Text - ' + text + ' ***');
                });
            });
        });
    }, function(reason){
        console.log('*** Table Rows Not Found - promise rejected ***');
        console.log(reason);
    });
});
it('Then I should get more than one cell returned', function() {
    expect(cellCount.count()).toBeGreaterThan(0);
});
</code>```

When running the test, I am seeing some Jasmine timeout errors followed by a failure for my expectation where it cannot call count() on my cells variable that gets assigned in the beforeAll block. Perhaps this timeout is related to what I am seeing but I am struggling to debug this further.

```<code>[12:20:01] I/testLogger - [chrome #01-6] PID: 9609
[chrome #01-6] Specs: /var/jenkins/workspace/project_x/test/e2e/features/featureA/workflow/SW0005.spec.js
[chrome #01-6]
[chrome #01-6] [12:18:56] I/direct - Using ChromeDriver directly...
[chrome #01-6] Started
[chrome #01-6] *** Comparison period selected ***
[chrome #01-6] [12:19:07] W/element - more than one element found for locator By(css selector, .spinnerContainer) - the first result will be used
[chrome #01-6] [12:19:41] W/element - more than one element found for locator By(css selector, .spinnerContainer) - the first result will be used
[chrome #01-6] *** Table Rows Found - promise resolved ***
[chrome #01-6] *** Number of Table Rows Found - 1 ***
[chrome #01-6] *** Number of Table Cells Found - 11 ***
[chrome #01-6] *** First Table Cell Text - blaa ***
[chrome #01-6] A Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] Failures:
[chrome #01-6]   Message:
[chrome #01-6] [31m    Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.[0m
[chrome #01-6]   Stack:
[chrome #01-6]     Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
[chrome #01-6]         at ontimeout (timers.js:365:14)
[chrome #01-6]         at tryOnTimeout (timers.js:237:5)
[chrome #01-6]         at Timer.listOnTimeout (timers.js:207:5)
[chrome #01-6]   Message:
[chrome #01-6] [31m    Failed: Cannot read property 'count' of undefined[0m
[chrome #01-6]   Stack:
[chrome #01-6]     TypeError: Cannot read property 'count' of undefined
</code>```

As can be seen from the console logs I have added, protractor is able to find a row and retrieve cells which I assign to my cells property (console log shows 11 cells), but it seems this is becoming undefined at the point the expectation is run. The cells property is defined outside of my beforeAll also, so I would have thought this would remain assigned and not undefined by the time the expectation check is performed.

This causes me problems for later tests where I want to read and check the values of each cell.

I feel like I am doing something fundamentally wrong, can anyone help?

Thanks

答:
By default Jasmine beforeAll, beforeEach, afterEach, afterAll and it will expect a timeout-variable as second/third parameter. Though your example is not explicitly mentioned, read about the timeout-parameter of jasmine here

Though your callback is from your helper-function, my assumption is, that your reason-function makes it fail, because Jasmine might not support every aspect of JavaScript.

Try without the reason-function:

```<code>beforeAll(function() {
    //all your test code

    }); //don't add ", function(reason){etc});
});
it('Then I should get more than one cell returned', function() {
    expect(cells.count()).toBeGreaterThan(0);
});
</code>```

Further the remark, that here you forgot to re-set "count", which is why your table rows and table cells are the same number:

```<code>cells = row.all(by.css('td'));
cells.count().then(function(count2){ //Here the "count" is missing
    console.log('*** Number of Table Cells Found - ' + count2 + ' ***');
</code>```

UPDATE

You're right, the callback is of your own function, not the helper.

I now just saw that you have errors "cannot read property 'count' of 'undefined' ". Therefore your object page.reimbursementCalculations might be empty.

Currently these two lines log the same variable:

```<code>console.log('*** Number of Table Rows Found - ' + count + ' ***');
console.log('*** Number of Table Cells Found - ' + count + ' ***');
</code>```

Body:
I am attempting to read out values from table cells on a row for checking values match as expected.

I am facing a situation where protractor is unable to get the text of particular cells I am interested in as it cannot find the cells I am querying.

Here is my test suite steps:

beforeAll(function() {
    common.journeyValidationBtn.click();
    helper.waitForUrlToContain('journey-validation');
    helper.waitForElementToHide(common.spinner);
    common.fabBtn.click();
    helper.waitForPresenceOf(common.calculateBtn);
    common.runCalculation(secondaryPeriod);
    helper.waitForPresenceOf(common.fabBtn, 30000);
    helper.waitForElementToHide(common.spinner);
    common.selectComparisonPeriod(initialPeriod);
    helper.waitForTableRows(page.reimbursementCalculations).then(function() {
        console.log('*** Table Rows Found - promise resolved ***');
        page.reimbursementCalculations.count().then(function(count){
            console.log('*** Number of Table Rows Found - ' + count + ' ***');
            row = page.reimbursementCalculations.first();
            cells = row.all(by.css('td'));
            cells.count().then(function(cellCount){
                console.log('*** Number of Table Cells Found - ' + cellCount + ' ***');
                cells.get(0).getText().then(function(text){
                    console.log('*** First Table Cell Text - ' + text + ' ***');
                });
            });
        });
    }, function(reason){
        console.log('*** Table Rows Not Found - promise rejected ***');
        console.log(reason);
    });
});
it('Then I should get more than one cell returned', function() {
    expect(cellCount.count()).toBeGreaterThan(0);
});

When running the test, I am seeing some Jasmine timeout errors followed by a failure for my expectation where it cannot call count() on my cells variable that gets assigned in the beforeAll block. Perhaps this timeout is related to what I am seeing but I am struggling to debug this further.

[12:20:01] I/testLogger - [chrome #01-6] PID: 9609
[chrome #01-6] Specs: /var/jenkins/workspace/project_x/test/e2e/features/featureA/workflow/SW0005.spec.js
[chrome #01-6]
[chrome #01-6] [12:18:56] I/direct - Using ChromeDriver directly...
[chrome #01-6] Started
[chrome #01-6] *** Comparison period selected ***
[chrome #01-6] [12:19:07] W/element - more than one element found for locator By(css selector, .spinnerContainer) - the first result will be used
[chrome #01-6] [12:19:41] W/element - more than one element found for locator By(css selector, .spinnerContainer) - the first result will be used
[chrome #01-6] *** Table Rows Found - promise resolved ***
[chrome #01-6] *** Number of Table Rows Found - 1 ***
[chrome #01-6] *** Number of Table Cells Found - 11 ***
[chrome #01-6] *** First Table Cell Text - blaa ***
[chrome #01-6] A Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] Failures:
[chrome #01-6]   Message:
[chrome #01-6] [31m    Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.[0m
[chrome #01-6]   Stack:
[chrome #01-6]     Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
[chrome #01-6]         at ontimeout (timers.js:365:14)
[chrome #01-6]         at tryOnTimeout (timers.js:237:5)
[chrome #01-6]         at Timer.listOnTimeout (timers.js:207:5)
[chrome #01-6]   Message:
[chrome #01-6] [31m    Failed: Cannot read property 'count' of undefined[0m
[chrome #01-6]   Stack:
[chrome #01-6]     TypeError: Cannot read property 'count' of undefined

As can be seen from the console logs I have added, protractor is able to find a row and retrieve cells which I assign to my cells property (console log shows 11 cells), but it seems this is becoming undefined at the point the expectation is run. The cells property is defined outside of my beforeAll also, so I would have thought this would remain assigned and not undefined by the time the expectation check is performed.

This causes me problems for later tests where I want to read and check the values of each cell.

I feel like I am doing something fundamentally wrong, can anyone help?

Thanks

Body:
By default Jasmine beforeAll, beforeEach, afterEach, afterAll and it will expect a timeout-variable as second/third parameter. Though your example is not explicitly mentioned, read about the timeout-parameter of jasmine here

Though your callback is from your helper-function, my assumption is, that your reason-function makes it fail, because Jasmine might not support every aspect of JavaScript.

Try without the reason-function:

beforeAll(function() {
    //all your test code

    }); //don't add ", function(reason){etc});
});
it('Then I should get more than one cell returned', function() {
    expect(cells.count()).toBeGreaterThan(0);
});

Further the remark, that here you forgot to re-set "count", which is why your table rows and table cells are the same number:

cells = row.all(by.css('td'));
cells.count().then(function(count2){ //Here the "count" is missing
    console.log('*** Number of Table Cells Found - ' + count2 + ' ***');

UPDATE

You're right, the callback is of your own function, not the helper.

I now just saw that you have errors "cannot read property 'count' of 'undefined' ". Therefore your object page.reimbursementCalculations might be empty.

Currently these two lines log the same variable:

console.log('*** Number of Table Rows Found - ' + count + ' ***');
console.log('*** Number of Table Cells Found - ' + count + ' ***');


问:
Set table view cell height by identifier - Swift
I am trying to set the height of each cell in the table view depending on the identifier. I do not want to use indexPath.row, because the i am filling the cell from an array containing a flag for each type of cell and the order is random. Exactly 3 types of cells.

I used this code but it causing an error:

```<code>func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {

    let cell = tableV.cellForRow(at: indexPath)
    if(cell?.reuseIdentifier == "homeFeaturedR"){
        return 200
    }else{
       return 360
    }
}
</code>```

The error is at this line:

```<code>let cell = tableV.cellForRow(at: indexPath)
</code>```

Thank you.

答: Seem like you wrong when select the tableView. You using the tableV not a tableView inside the function heightForRowAt indexPath. Let's change that and try again even this isn't a best ways in my mind.

Body:
I am trying to set the height of each cell in the table view depending on the identifier. I do not want to use indexPath.row, because the i am filling the cell from an array containing a flag for each type of cell and the order is random. Exactly 3 types of cells.

I used this code but it causing an error:

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {

    let cell = tableV.cellForRow(at: indexPath)
    if(cell?.reuseIdentifier == "homeFeaturedR"){
        return 200
    }else{
       return 360
    }
}

The error is at this line:

let cell = tableV.cellForRow(at: indexPath)

Thank you.


问:
Powershell variable Path
I'm sorry if that question already got asked but I didn't find anything around  here so here I go:

So I wrote a little PowerShell Script to ease the work for our IT Colleagues (Ping IPs/Computernames, open the Log files of the User, start a remote job of the computer etc.)

To start a remote job on given IP / Computername, I used this:

```<code>C:\Users\user\Desktop\Toolv1\RemoteControlViewer_SCCM2012\CmRcViewer.exe $objTextBox.Text
</code>```

This works fine on my Computer at the moment, but how do I insert a variable Path that uses the current Path + *\RemoteControlViewer_SCCM2012\CmRcViewer.exe $objTextBox.Text so I can share my Script with my colleagues without changing the Path each time in the script?

I already tried things like:

```<code>($PSScriptRoot + \RemoteControlViewer_SCCM2012\CmRcViewer.exe) $objTextBox.Text
</code>```

But I guess I'm doing something wrong.

Any tips?

答:
Use Join-Path to construct the full path, then & to invoke the executable:

```<code>& (Join-Path $PSScriptRoot RemoteControlViewer_SCCM2012\CmRcViewer.exe) $objTextBox.Text
</code>```

Title: Powershell variable Path

Body:
I'm sorry if that question already got asked but I didn't find anything around  here so here I go:

So I wrote a little PowerShell Script to ease the work for our IT Colleagues (Ping IPs/Computernames, open the Log files of the User, start a remote job of the computer etc.)

To start a remote job on given IP / Computername, I used this:

C:\Users\user\Desktop\Toolv1\RemoteControlViewer_SCCM2012\CmRcViewer.exe $objTextBox.Text

This works fine on my Computer at the moment, but how do I insert a variable Path that uses the current Path + *\RemoteControlViewer_SCCM2012\CmRcViewer.exe $objTextBox.Text so I can share my Script with my colleagues without changing the Path each time in the script?

I already tried things like:

($PSScriptRoot + \RemoteControlViewer_SCCM2012\CmRcViewer.exe) $objTextBox.Text

But I guess I'm doing something wrong.

Any tips?

Body:
Use Join-Path to construct the full path, then & to invoke the executable:

& (Join-Path $PSScriptRoot RemoteControlViewer_SCCM2012\CmRcViewer.exe) $objTextBox.Text


问:
Expression must have same datatype error while executing a query
Need your help in resolving the error which I'm getting. I'm using a union to join two queries and is giving me an error. Below is the query along with the error message.

Query:

```<code>SELECT 'Firewall Rules' as Platform
       , 'TestCount' TestCount
       , 'TestPassCount' TestPassCount
       , percentage as percentage
       , firewall_name as Server
from(
    SELECT round(avg(replace(PER_OF_VIOLATING_RULES, '%', ''))* 1 , 2)||'%'  as percentage
           , firewall_name
    from table1
    group by firewall_name
)
union
select 'Database' as Platform
       , count( *) TestCount
       , count(case when result_status = 'Not A Finding' then 1 end) TestPassCount
       , Round(  count(case when result_status = 'Not A Finding' then 1 end) / count(*) * 100 , 2) percentage
       , asset as Server
FROM table2
group by asset
</code>```

Error message:

```<code>ORA-01790: expression must have the same datatype as corresponding expression
01790. 00000 -  "expression must have the same datatype as the corresponding expression"
*Cause:
*Action:
Error at Line: 1 Column: 37
</code>```

Can someone help in modifying the query?

答:
With set operations the projection of all the subqueries must have the same signature. So the datatypes of the columns must match.

With your top subquery you are returning string literals for TestCount and TestPassCount but numbers for the bottom subquery. So you need to change one of those projections. You could use to_char() to cast the numerics to strings but it would be better to remove the string literals in the firewall subquery:

```<code>SELECT 'Firewall Rules' as Platform
       , to_number(null) TestCount
       , to_number(null) TestPassCount
       , percentage as percentage
....
</code>```

Alternatively you could use literal zeroes, it depends on your needs.

By the way: you can use UNION ALL rather than UNION, because the result set of both subqueries is guaranteed to be a set due to the platform literal. UNION does a sort to ensure uniqueness, so for a big query UNION ALL is more efficient.

Body:
Need your help in resolving the error which I'm getting. I'm using a union to join two queries and is giving me an error. Below is the query along with the error message.

Query:

SELECT 'Firewall Rules' as Platform
       , 'TestCount' TestCount
       , 'TestPassCount' TestPassCount
       , percentage as percentage
       , firewall_name as Server
from(
    SELECT round(avg(replace(PER_OF_VIOLATING_RULES, '%', ''))* 1 , 2)||'%'  as percentage
           , firewall_name
    from table1
    group by firewall_name
)
union
select 'Database' as Platform
       , count( *) TestCount
       , count(case when result_status = 'Not A Finding' then 1 end) TestPassCount
       , Round(  count(case when result_status = 'Not A Finding' then 1 end) / count(*) * 100 , 2) percentage
       , asset as Server
FROM table2
group by asset

Error message:

ORA-01790: expression must have the same datatype as corresponding expression
01790. 00000 -  "expression must have the same datatype as the corresponding expression"
*Cause:
*Action:
Error at Line: 1 Column: 37

Can someone help in modifying the query?

Body:
With set operations the projection of all the subqueries must have the same signature. So the datatypes of the columns must match.

With your top subquery you are returning string literals for TestCount and TestPassCount but numbers for the bottom subquery. So you need to change one of those projections. You could use to_char() to cast the numerics to strings but it would be better to remove the string literals in the firewall subquery:

SELECT 'Firewall Rules' as Platform
       , to_number(null) TestCount
       , to_number(null) TestPassCount
       , percentage as percentage
....

Alternatively you could use literal zeroes, it depends on your needs.

By the way: you can use UNION ALL rather than UNION, because the result set of both subqueries is guaranteed to be a set due to the platform literal. UNION does a sort to ensure uniqueness, so for a big query UNION ALL is more efficient.


问:
JQuery datepicker not working after ajax call
I have the following code

```<code><html>
    <head>
       //included all jquery related stuff ..not shown here
    </head>
    <body>
       <button id = 'btn' />
       <div id = 'ct'>
             <?php echo file_get_contents('my_ajax_stuff.php'); ?>
       </div>
    </body>
    <script>
       $('.datepicker').datepicker({dateFormat: "dd-mm-yy"});
       $('#btn').click(function() {
           $.ajax({
            type: "GET",
            url: "my_ajax_stuff.php" ,
            success: function(response) {
                $('#ct').html(response);
                /*added following line to solve this issue ..but not worked*/
                //$( ".datepicker" ).datepicker({dateFormat: "dd-mm-yy"});

            } ,
            error: function () {
                $('#ct').html("Some problem fetching data.Please try again");
            }
        });
       });
    </script>
</html>
</code>```

The page

my_ajax_stuff.php

contains a jquery ui datepicker with class = 'datepicker'.On the first load the datepicker works.But when I click on the button to reload it again , the contents are replaced with new contents.But the datepicker is not working.I have tried initialising the datepicker inside the ajax success handler ,as you see.But it also failed.What is the issue.How can it be solved???

答:
Call your picker inside .ajaxComplete function.

```<code>$(document).ready(function () {
    // setup picker here...
});

$(document).ajaxComplete(function() {
   // setup picker here...
});
</code>```

Here is a link

Body:
I have the following code

       //included all jquery related stuff ..not shown here

       <button id = 'btn' />

             <?php echo file_get_contents('my_ajax_stuff.php'); ?>

The page

my_ajax_stuff.php

contains a jquery ui datepicker with class = 'datepicker'.On the first load the datepicker works.But when I click on the button to reload it again , the contents are replaced with new contents.But the datepicker is not working.I have tried initialising the datepicker inside the ajax success handler ,as you see.But it also failed.What is the issue.How can it be solved???

Body:
Call your picker inside .ajaxComplete function.

$(document).ready(function () {
    // setup picker here...
});

$(document).ajaxComplete(function() {
   // setup picker here...
});

Here is a link