Rectangle 27 320

I fixed it by opening Xcode Preferences (+,), going to Accounts View Details. Then select all provisioning profiles and delete them with backspace (note: they can't be removed in Xcode 7.2). Restart Xcode, else the list doesn't seem to update properly.

Now click the Download all button, and you should have all provisioning profiles that you defined in the Member center back in Xcode. Don't worry about the Xcode-generated ones (Prefixed with XC:), Xcode will regenerate them if necessary. Restart Xcode again.

Now go to the Code Signing section in your Build Settings and select the correct profile and cert.

Just deleting the provisioning profiles and downloading again did not help. I have to quit Xcode and reopen again.

Xcode 7.3: You can no longer highlight (or delete?) Provisioning Profiles. Hitting backspace is just ignored. "Xcode. Each release makes you hate it just a little bit more. (tm)"

In Xcode 7.3, instead of hitting backspace, you can right-click on the profile and select "Move to Trash".

ios - Xcode 7.2 no matching provisioning profiles found - Stack Overfl...

ios xcode provisioning-profile
Rectangle 27 320

I fixed it by opening Xcode Preferences (+,), going to Accounts View Details. Then select all provisioning profiles and delete them with backspace (note: they can't be removed in Xcode 7.2). Restart Xcode, else the list doesn't seem to update properly.

Now click the Download all button, and you should have all provisioning profiles that you defined in the Member center back in Xcode. Don't worry about the Xcode-generated ones (Prefixed with XC:), Xcode will regenerate them if necessary. Restart Xcode again.

Now go to the Code Signing section in your Build Settings and select the correct profile and cert.

Just deleting the provisioning profiles and downloading again did not help. I have to quit Xcode and reopen again.

Xcode 7.3: You can no longer highlight (or delete?) Provisioning Profiles. Hitting backspace is just ignored. "Xcode. Each release makes you hate it just a little bit more. (tm)"

In Xcode 7.3, instead of hitting backspace, you can right-click on the profile and select "Move to Trash".

ios - Xcode 7.2 no matching provisioning profiles found - Stack Overfl...

ios xcode provisioning-profile
Rectangle 27 320

I fixed it by opening Xcode Preferences (+,), going to Accounts View Details. Then select all provisioning profiles and delete them with backspace (note: they can't be removed in Xcode 7.2). Restart Xcode, else the list doesn't seem to update properly.

Now click the Download all button, and you should have all provisioning profiles that you defined in the Member center back in Xcode. Don't worry about the Xcode-generated ones (Prefixed with XC:), Xcode will regenerate them if necessary. Restart Xcode again.

Now go to the Code Signing section in your Build Settings and select the correct profile and cert.

Just deleting the provisioning profiles and downloading again did not help. I have to quit Xcode and reopen again.

Xcode 7.3: You can no longer highlight (or delete?) Provisioning Profiles. Hitting backspace is just ignored. "Xcode. Each release makes you hate it just a little bit more. (tm)"

In Xcode 7.3, instead of hitting backspace, you can right-click on the profile and select "Move to Trash".

ios - Xcode 7.2 no matching provisioning profiles found - Stack Overfl...

ios xcode provisioning-profile
Rectangle 27 41

This may be a niche reason to perform an update (for example, mainly used in a procedure), or may be obvious to others, but it should also be stated that you can perform an update-select statement without using join (in case the tables you're updating between have no common field).

update
    Table
set
    Table.example = a.value
from
    TableExample a
where
    Table.field = *key value* -- finds the row in Table 
    AND a.field = *key value* -- finds the row in TableExample a

How do I UPDATE from a SELECT in SQL Server? - Stack Overflow

sql sql-server tsql select
Rectangle 27 41

This may be a niche reason to perform an update (for example, mainly used in a procedure), or may be obvious to others, but it should also be stated that you can perform an update-select statement without using join (in case the tables you're updating between have no common field).

update
    Table
set
    Table.example = a.value
from
    TableExample a
where
    Table.field = *key value* -- finds the row in Table 
    AND a.field = *key value* -- finds the row in TableExample a

How do I UPDATE from a SELECT in SQL Server? - Stack Overflow

sql sql-server tsql select
Rectangle 27 41

This may be a niche reason to perform an update (for example, mainly used in a procedure), or may be obvious to others, but it should also be stated that you can perform an update-select statement without using join (in case the tables you're updating between have no common field).

update
    Table
set
    Table.example = a.value
from
    TableExample a
where
    Table.field = *key value* -- finds the row in Table 
    AND a.field = *key value* -- finds the row in TableExample a

How do I UPDATE from a SELECT in SQL Server? - Stack Overflow

sql sql-server tsql select
Rectangle 27 157

From the "Updating Chosen Dynamically" section in the docs: You need to trigger the 'chosen:updated' event on the field

$(document).ready(function() {

    $('select').chosen();

    $('button').click(function() {
        $('select').val(2);
        $('select').trigger("chosen:updated");
    });

});
$('select').trigger("liszt:updated");

FYI: they've updated to 1.0 which now uses chosen:updated instead of liszt:updated

I stumbled here as I was trying to find a way to select the best currently matching option from a multi select chosen search result list (whenever focus was lost). Here's a short fiddle about my explorations. You don't event need to trigger any events. Perhaps, it is of use for someone else too... :)

I know this is an old post - but a simpler way to update is just in one string: $('select').val(2).trigger("chosen:updated");

@Lucas Welper: you should also change $('select').val(2); into $('select').val(2).change();, because changing the selected option of a select with jQuery doesn't trigger the change event and some people might need it.

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

javascript - Changing selection in a select with the Chosen plugin - S...

javascript jquery select jquery-chosen
Rectangle 27 23

Updating through CTE is more readable than the other answer's here:

;WITH cte
     AS (SELECT col1,col2,id
         FROM   other_table
         WHERE  sql = 'cool')
UPDATE A
SET    A.col1 = B.col1,
       A.col2 = B.col2
FROM   table A
       INNER JOIN cte B
               ON A.id = B.id

How do I UPDATE from a SELECT in SQL Server? - Stack Overflow

sql sql-server tsql select
Rectangle 27 23

Updating through CTE is more readable than the other answer's here:

;WITH cte
     AS (SELECT col1,col2,id
         FROM   other_table
         WHERE  sql = 'cool')
UPDATE A
SET    A.col1 = B.col1,
       A.col2 = B.col2
FROM   table A
       INNER JOIN cte B
               ON A.id = B.id

How do I UPDATE from a SELECT in SQL Server? - Stack Overflow

sql sql-server tsql select
Rectangle 27 23

Updating through CTE is more readable than the other answer's here:

;WITH cte
     AS (SELECT col1,col2,id
         FROM   other_table
         WHERE  sql = 'cool')
UPDATE A
SET    A.col1 = B.col1,
       A.col2 = B.col2
FROM   table A
       INNER JOIN cte B
               ON A.id = B.id

How do I UPDATE from a SELECT in SQL Server? - Stack Overflow

sql sql-server tsql select
Rectangle 27 12

UPDATE TQ
SET TQ.IsProcessed = 1, TQ.TextName = 'bla bla bla'
FROM TableQueue TQ
INNER JOIN TableComment TC ON TC.ID = TQ.TCID
WHERE TQ.IsProcessed = 0

To make sure you are updating what you want, select first

SELECT TQ.IsProcessed, 1 AS NewValue1, TQ.TextName, 'bla bla bla' AS NewValue2
FROM TableQueue TQ
INNER JOIN TableComment TC ON TC.ID = TQ.TCID
WHERE TQ.IsProcessed = 0

How do I UPDATE from a SELECT in SQL Server? - Stack Overflow

sql sql-server tsql select
Rectangle 27 11

UPDATE TQ
SET TQ.IsProcessed = 1, TQ.TextName = 'bla bla bla'
FROM TableQueue TQ
INNER JOIN TableComment TC ON TC.ID = TQ.TCID
WHERE TQ.IsProcessed = 0

To make sure you are updating what you want, select first

SELECT TQ.IsProcessed, 1 AS NewValue1, TQ.TextName, 'bla bla bla' AS NewValue2
FROM TableQueue TQ
INNER JOIN TableComment TC ON TC.ID = TQ.TCID
WHERE TQ.IsProcessed = 0

How do I UPDATE from a SELECT in SQL Server? - Stack Overflow

sql sql-server tsql select
Rectangle 27 11

UPDATE TQ
SET TQ.IsProcessed = 1, TQ.TextName = 'bla bla bla'
FROM TableQueue TQ
INNER JOIN TableComment TC ON TC.ID = TQ.TCID
WHERE TQ.IsProcessed = 0

To make sure you are updating what you want, select first

SELECT TQ.IsProcessed, 1 AS NewValue1, TQ.TextName, 'bla bla bla' AS NewValue2
FROM TableQueue TQ
INNER JOIN TableComment TC ON TC.ID = TQ.TCID
WHERE TQ.IsProcessed = 0

How do I UPDATE from a SELECT in SQL Server? - Stack Overflow

sql sql-server tsql select
Rectangle 27 572

In MySQL, you can't modify the same table which you use in the SELECT part. This behaviour is documented at: http://dev.mysql.com/doc/refman/5.6/en/update.html

Maybe you can just join the table to itself

You will need to stop using the nested subquery and execute the operation in two parts, or alternatively use a simple where clause.

However, you can do multi-table updates like this:

If the logic is simple enough to re-shape the query, lose the subquery and join the table to itself, employing appropriate selection criteria. This will cause MySQL to see the table as two different things, allowing destructive changes to go ahead.

UPDATE tbl AS a
  INNER JOIN tbl AS b ON ....
  SET a.col = b.col
UPDATE tbl AS a
INNER JOIN tbl AS b ON ....
SET a.col = b.col

Alternatively, try nesting the subquery deeper into a from clause ...

If you absolutely need the subquery, there's a workaround, but it's ugly for several reasons, including performance:

UPDATE tbl SET col = (
  SELECT ... FROM (SELECT.... FROM) AS x);

The nested subquery in the FROM clause creates an implicit temporary table, so it doesn't count as the same table you're updating.

Could have just saved myself half an hour of angst if I'd read this first.

... but watch out for the query optimiser

The temp table might be ugly, but it gets the job done. +1

However, beware that from MySQL 5.7.6 and onward, the optimiser may optimise out the subquery, and still give you the error. Luckily, the optimizer_switch variable can be used to switch off this behaviour; although I couldn't recommend doing this as anything more than a short term fix, or for small one-off tasks.

The last workaround is both the stupidest and best thing I've ever seen.

SET optimizer_switch = 'derived_merge=off';

Upvoted this answer because I had to delete items and could not get info from another table, had to subquery from same table. Since this is what pops up on top while googling for the error I got this would be the best fit answer for me and a lot of people trying to update while subquerieing from the same table.

@Cheekysoft, Why not save the values into variables instead?

Beware, that from MySQL 5.7.6 on, the optimizer may optimize the sub-query away and still give you the error, unless you SET optimizer_switch = 'derived_merge=off'; :-(

@PeterV.Mrch Following mysqlserverteam.com/derived-tables-in-mysql-5-7, in case certain operations are carried out, merging cannot happen. E.g. provide the derived dummy table with a LIMIT (to inifity) and the error will never occur. That's pretty hackish though and there is still the risk that future versions of MySQL will support merging queries with LIMIT after all.

subquery - MySQL Error 1093 - Can't specify target table for update in...

mysql subquery sql-delete mysql-error-1093
Rectangle 27 560

In MySQL, you can't modify the same table which you use in the SELECT part. This behaviour is documented at: http://dev.mysql.com/doc/refman/5.6/en/update.html

Maybe you can just join the table to itself

If the logic is simple enough to re-shape the query, lose the subquery and join the table to itself, employing appropriate selection criteria. This will cause MySQL to see the table as two different things, allowing destructive changes to go ahead.

UPDATE tbl AS a
INNER JOIN tbl AS b ON ....
SET a.col = b.col

Alternatively, try nesting the subquery deeper into a from clause ...

If you absolutely need the subquery, there's a workaround, but it's ugly for several reasons, including performance:

UPDATE tbl SET col = (
  SELECT ... FROM (SELECT.... FROM) AS x);

The nested subquery in the FROM clause creates an implicit temporary table, so it doesn't count as the same table you're updating.

... but watch out for the query optimiser

However, beware that from MySQL 5.7.6 and onward, the optimiser may optimise out the subquery, and still give you the error. Luckily, the optimizer_switch variable can be used to switch off this behaviour; although I couldn't recommend doing this as anything more than a short term fix, or for small one-off tasks.

SET optimizer_switch = 'derived_merge=off';

Upvoted this answer because I had to delete items and could not get info from another table, had to subquery from same table. Since this is what pops up on top while googling for the error I got this would be the best fit answer for me and a lot of people trying to update while subquerieing from the same table.

@Cheekysoft, Why not save the values into variables instead?

Beware, that from MySQL 5.7.6 on, the optimizer may optimize the sub-query away and still give you the error, unless you SET optimizer_switch = 'derived_merge=off'; :-(

@PeterV.Mrch Following mysqlserverteam.com/derived-tables-in-mysql-5-7, in case certain operations are carried out, merging cannot happen. E.g. provide the derived dummy table with a LIMIT (to inifity) and the error will never occur. That's pretty hackish though and there is still the risk that future versions of MySQL will support merging queries with LIMIT after all.

subquery - MySQL Error 1093 - Can't specify target table for update in...

mysql subquery sql-delete mysql-error-1093
Rectangle 27 136

Setting the select element's value to an empty string is the correct way to do it. However, that only updates the root select element. The custom chosen element has no idea that the root select has been updated.

In order to notify chosen that the select has been modified, you have to trigger chosen:updated:

or, if you're not sure that the first option is an empty string, use this:

$('#autoship_option')
    .find('option:first-child').prop('selected', true)
    .end().trigger('chosen:updated');

P.S. Older versions of Chosen use a slightly different event:

$('#autoship_option').val('').trigger('liszt:updated');

That worked like a charm. I had a feeling I was missing something with Chosen. Thank you very much. :)

Argh, why isn't this in the documentation (or did I just miss it?) Thanks for this.

.trigger("chosen:updated");
.find('option').removeAttr('selected').end().trigger('chosen:updated')

How do I reset a jquery-chosen select option with jQuery? - Stack Over...

jquery jquery-chosen
Rectangle 27 2

The key to making this work is to do the work in the server, rather than making the server select each row, pass it to the client, and then accept the data back from the client.

UPDATE YourTable
   SET y = (CASE WHEN z > x THEN p ELSE y)
 WHERE key_column BETWEEN lo_val AND hi_val;

The complicated part will likely be splitting the work into manageable sub-transactions; that's what the 'lo_val .. hi_val' condition is about. If your logical logs are big enough to handle all 130 million rows being updated [about (2 * (row size + X) * number of rows), with X being a value around 20, I believe] with space to spare, then you can do it all at once. Clearly, this 'updates' every row.

If you decide you must do it in the client (a mistake, but ...), then:

You use a SELECT cursor with HOLD so that it stays open and correctly positioned across transactions. You start a transaction, fetch a few thousand rows, updating each one as needed. Make sure you are using a prepared UPDATE statement; maybe you use a WHERE CURRENT OF condition.

No, though you could do it in a stored procedure. It depends in part on whether this is something you're going to do on a regular basis; if so, maybe the stored procedure is a good idea, but I wouldn't for a one-off exercise.

It depends on how you are going to determine lo_val and hi_val. I'd probably use I4GL (because I'm fluent in it) and then I'd expect to prepare the UPDATE statement (with question marks in place of 'lo_val' and 'hi_val'), and then I'd expect to execute it a number of times, each time forming a single statement transaction. So, if you decided to go with a ranges of lo_val..hi_val from 000000..099999, 100000..199999, ... then you'd iterate:

for i = 0 to 10000000 step 100000
    let j = i + 99999
    execute p_update using i, j
end for

In I4GL you would not absolutely need to use a prepared statement. If you have IDS 11, you can prepare statements in SPL. In earlier versions, and without much of a performance hit (I doubt if you could measure it reliably), you could simply use:

CREATE PROCEDURE update_your_table()
    DEFINE lo_val, hi_val INTEGER;

    FOR lo_val = 0 TO 1000000 STEP 100000
        LET hi_val = lo_val + 99999;
        UPDATE YourTable
           SET y = (CASE WHEN z > x THEN p ELSE y)
         WHERE key_column BETWEEN lo_val AND hi_val;
    END FOR;

END PROCEDURE;

Do you suggest to put the update as part of the cursor in a stored procedure? Since I'm new to stored procedures, I can't seem to wrap my head around them.

Thanks for your detailed explanation Jonathan. Very helpful. This is going to be an one-off activity. I don't quite understand about I4GL. Do you have any links pointing to that. Google search does not give me convincing result.

@prabhu: I4GL is also Informix 4GL. It is a good language for working with Informix databases. If you don't know about it and don't have it on your machine, don't worry about it for this exercise. Use a stored procedure - or write it in ODBC, JDBC, ESQL/C or any other language/API of your choosing that you have available.

informix - Proper way of declaring cursor for huge number of updates -...

informix embedded-sql
Rectangle 27 3

There is no problem in adding a ng-model because that will help you to use its value. For example:

Now you can read the selected customer's value in your controller by simply $scope.selectedCustomer.

After updating the question with more description, you have two option:

You can write like this (although, you can achieve much of it in the HTML itself but it is cleaner to do in the controller):

$scope.customerSelected = function() {
     var selectedCustomer = $scope.selectedCustomer;
     if (!selectedCustomer) {
          alert("Please select a customer");
          return;
     }

     var secondId = selectedCustomer.split('|')[2];
     // You can directly put your main logic here but since you want to
     // call a separate method with passing the id
     $scope.doSomethingWithCustomer(secondId);
};

$scope.doSomethingWithCustomer = function(id) {
    // Your main logic here after selecting the customer
};

and modify your HTML as I described above:

$scope.doSomethingWithCustomer = function(id) {
    // Your main logic here after selecting the 2nd customer
};

and modify your HTML as:

If you want to achieve it without the ng-model and without jQuery then you can use a directive:

See a working example below.

var a = angular.module("sa", [])

a.controller("foobar", function($scope) {
  $scope.getCustomerName = function() {
    return ['Foo', 'Bar'];
  };

  $scope.customerSelected = function() {
    console.log("I'm changed");
    alert("I'm changed");
  };
});

a.directive("changeMe", function() {
  return {
    scope: {
      changeMe: '&'
    },
    link: function($scope, element, attr) {
      element.on("change", function() {
           $scope.changeMe();
      })
    }
  }
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<div ng-app="sa" ng-controller="foobar">
  <select class="account-filter" change-me="customerSelected()">
    <option ng-repeat="account in getCustomerName() track by $index" ng-class="(account | limitTo: 18)" ng-bind="account.split('|')[0]"></option>
  </select>
</div>

@VinodBhavnani I've updated the answer.

<select class="account-filter" ng-model="selectedCustomer"     ng-change="customerSelected(selectedCustomer.split('|')[0])">       <option ng-repeat="account in getCustomerName() track by $index" ng-class="(account | limitTo: 18)" ng-bind="account.split('|')[0]"></option> </select>

I may be talking rubbish, but I thought that ng-model will just give you the selected value text. So if the dropdown value itself is name, which was split from name|Number|Number2, in ng-model also will I not get just name? i want Number.

javascript - Call a function on change of a select option in angularjs...

javascript angularjs
Rectangle 27 3

What's even cooler is the fact that you can use an inline Table-Valued Function to select which (and how many via TOP) row(s) to update. That is:

UPDATE MyTable
SET Column1=@Value1
FROM tvfSelectLatestRowOfMyTableMatchingCriteria(@Param1,@Param2,@Param3)

For the table valued function you have something interesting to select the row to update like:

CREATE FUNCTION tvfSelectLatestRowOfMyTableMatchingCriteria
(
    @Param1 INT,
    @Param2 INT,
    @Param3 INT
)
RETURNS TABLE AS RETURN
(
    SELECT TOP(1) MyTable.*
    FROM MyTable
    JOIN MyOtherTable
      ON ...
    JOIN WhoKnowsWhatElse
      ON ...
    WHERE MyTable.SomeColumn=@Param1 AND ...
    ORDER BY MyTable.SomeDate DESC
)

..., and there lies (in my humble opinion) the true power of updating only top selected rows deterministically while at the same time simplifying the syntax of the UPDATE statement.

how can I Update top 100 records in sql server - Stack Overflow

sql sql-server sql-update
Rectangle 27 2

Just append new text elements for each additional information and adjust the dy positions to place them suitably. Also don't forget to use selectAll instead of select for updating fill-opacity of text elements during collapse/expand actions.

var flare = {
 "name": "flare",
  "info1": "flare subtext 1",
  "info2": "flare subtext 2",
 "children": [
  {
   "name": "analytics",
   "info1": "analytics subtext 1",
   "info2": "analytics subtext 2",
   "children": [
    {
     "name": "cluster",
     "info1": "cluster subtext 1",
     "info2": "cluster subtext 2",
     "children": [
      {"name": "AgglomerativeCluster", "size": 3938,"info1": "AgglomerativeCluster subtext 1","info2": "AgglomerativeCluster subtext 2"}    
     ]
    },    
    {
     "name": "optimization",
         "info1": "optimization subtext 1",
   "info2": "optimization subtext 2",
     "children": [
      {"name": "AspectRatioBanker", "size": 7074,"info1": "AspectRatioBanker subtext 1","info2": "AspectRatioBanker subtext 2"}
     ]
    }
   ]
  },
  {
   "name": "animate",
       "info1": "animate subtext 1",
   "info2": "animate subtext 2",
   "children": [
    {"name": "Easing", "size": 17010,"info1": "Easing subtext 1","info2": "Easing subtext 2"}        
   ]
  }
 ]
};
var margin = {top: 20, right: 120, bottom: 20, left: 120},
    width = 960 - margin.right - margin.left,
    height = 800 - margin.top - margin.bottom;

var i = 0,
    duration = 750,
    root;

var tree = d3.layout.tree()
    .size([height, width]);

var diagonal = d3.svg.diagonal()
    .projection(function(d) { return [d.y, d.x]; });

var svg = d3.select("body").append("svg")
    .attr("width", width + margin.right + margin.left)
    .attr("height", height + margin.top + margin.bottom)
  .append("g")
    .attr("transform", "translate(" + margin.left + "," + margin.top + ")");


  root = flare;
  root.x0 = height / 2;
  root.y0 = 0;

  function collapse(d) {
    if (d.children) {
      d._children = d.children;
      d._children.forEach(collapse);
      d.children = null;
    }
  }

  root.children.forEach(collapse);
  update(root);


d3.select(self.frameElement).style("height", "800px");

function update(source) {

  // Compute the new tree layout.
  var nodes = tree.nodes(root).reverse(),
      links = tree.links(nodes);

  // Normalize for fixed-depth.
  nodes.forEach(function(d) { d.y = d.depth * 180; });

  // Update the nodes
  var node = svg.selectAll("g.node")
      .data(nodes, function(d) { return d.id || (d.id = ++i); });

  // Enter any new nodes at the parent's previous position.
  var nodeEnter = node.enter().append("g")
      .attr("class", "node")
      .attr("transform", function(d) { return "translate(" + source.y0 + "," + source.x0 + ")"; })
      .on("click", click);

  nodeEnter.append("circle")
      .attr("r", 1e-6)
      .style("fill", function(d) { return d._children ? "lightsteelblue" : "#fff"; });

  nodeEnter.append("text")
      .attr("x", function(d) { return d.children || d._children ? -10 : 10; })
      .attr("dy", "-.75em")
      .attr("text-anchor", function(d) { return d.children || d._children ? "end" : "start"; })
      .text(function(d) { return d.name; })
      .style("fill-opacity", 1e-6);
  
    nodeEnter.append("text")
      .attr("x", function(d) { return d.children || d._children ? -10 : 10; })
      .attr("dy", "1.00em")
      .attr("text-anchor", function(d) { return d.children || d._children ? "end" : "start"; })
      .text(function(d) { return d.info1; })
      .style("fill-opacity", 1e-6);
  
      nodeEnter.append("text")
      .attr("x", function(d) { return d.children || d._children ? -10 : 10; })
      .attr("dy", "2.35em")
      .attr("text-anchor", function(d) { return d.children || d._children ? "end" : "start"; })
      .text(function(d) { return d.info2; })
      .style("fill-opacity", 1e-6);

  // Transition nodes to their new position.
  var nodeUpdate = node.transition()
      .duration(duration)
      .attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; });

  nodeUpdate.select("circle")
      .attr("r", 4.5)
      .style("fill", function(d) { return d._children ? "lightsteelblue" : "#fff"; });

  nodeUpdate.selectAll("text")
      .style("fill-opacity", 1);

  // Transition exiting nodes to the parent's new position.
  var nodeExit = node.exit().transition()
      .duration(duration)
      .attr("transform", function(d) { return "translate(" + source.y + "," + source.x + ")"; })
      .remove();

  nodeExit.select("circle")
      .attr("r", 1e-6);

  nodeExit.selectAll("text")
      .style("fill-opacity", 1e-6);

  // Update the links
  var link = svg.selectAll("path.link")
      .data(links, function(d) { return d.target.id; });

  // Enter any new links at the parent's previous position.
  link.enter().insert("path", "g")
      .attr("class", "link")
      .attr("d", function(d) {
        var o = {x: source.x0, y: source.y0};
        return diagonal({source: o, target: o});
      });

  // Transition links to their new position.
  link.transition()
      .duration(duration)
      .attr("d", diagonal);

  // Transition exiting nodes to the parent's new position.
  link.exit().transition()
      .duration(duration)
      .attr("d", function(d) {
        var o = {x: source.x, y: source.y};
        return diagonal({source: o, target: o});
      })
      .remove();

  // Stash the old positions for transition.
  nodes.forEach(function(d) {
    d.x0 = d.x;
    d.y0 = d.y;
  });
}

// Toggle children on click.
function click(d) {
  if (d.children) {
    d._children = d.children;
    d.children = null;
  } else {
    d.children = d._children;
    d._children = null;
  }
  update(d);
}
.node {
  cursor: pointer;
}

.node circle {
  fill: #fff;
  stroke: steelblue;
  stroke-width: 1.5px;
}

.node text {
  font: 10px sans-serif;
}

.link {
  fill: none;
  stroke: #ccc;
  stroke-width: 1.5px;
}
<script src="//d3js.org/d3.v3.min.js"></script>

Here in the data selection we are using directly with the name (i.e d.children ) . Can we use any function? something like d.getChildren(index_number) ?? So that we should not hardcode the children or subnode name as in data?

javascript - D3.js Collapsible tree - Show more than only name of node...

javascript d3.js