Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用数字增加列值_Javascript_Angularjs_Angular Components - Fatal编程技术网

Javascript 如何使用数字增加列值

Javascript 如何使用数字增加列值,javascript,angularjs,angular-components,Javascript,Angularjs,Angular Components,我已经用字母表实现了下面的组件rowid,但是我需要用numberic来更改它。在我实现的组件中有一个名为RowId的列,当我们单击+按钮时,如果我按下+父RowId+以起始字母开始,这个RowId将增加。下面是我已经实现的组件 我需要用numeric实现rowid,因为字母表只能从A到Z工作,而Z rowid就像特殊的字符一样。所以我需要用numeric实现这个功能。所以我将克服这个问题 var newRow = { "rowId": "A" } $scope.componen

我已经用字母表实现了下面的组件rowid,但是我需要用numberic来更改它。在我实现的组件中有一个名为RowId的列,当我们单击
+
按钮时,如果我按下
+
父RowId+以起始字母开始,这个RowId将增加。下面是我已经实现的组件

我需要用numeric实现rowid,因为字母表只能从A到Z工作,而Z rowid就像特殊的字符一样。所以我需要用numeric实现这个功能。所以我将克服这个问题

var newRow = {
    "rowId": "A"
  }
  $scope.componentList = [];
  $scope.componentList.push(angular.copy(newRow));

  $scope.addParentRow = function(rowId) {
    var newGridRow = angular.copy(newRow);
    var lastChar = getListOfSameLevel(rowId, true); //isParentRow
    var parentId = rowId.length > 1 ? rowId.slice(0, rowId.length - 1) : "";
    newGridRow.rowId = parentId + getNextChar(lastChar);
    $scope.componentList.push(newGridRow);
  }

  $scope.addChildRow = function(rowId) {
    var newGridRow = angular.copy(newRow);
    var lastChar = getListOfSameLevel(rowId, false);
    if (rowId.length === lastChar.length) {
      newGridRow.rowId = rowId + "A";
    } else {
      var parentId = lastChar.length > 1 ? lastChar.slice(0, lastChar.length - 1) : "";
      newGridRow.rowId = parentId + getNextChar(getLastChar(lastChar));
    }
    $scope.componentList.push(newGridRow);
  };

  var getNextChar = function(inputChar) {
    return String.fromCharCode(inputChar.charCodeAt(0) + 1);
  };

  var getLastChar = function(fullStr) {
    return fullStr.slice(-1);
  };

  var getListOfSameLevel = function(rowId, isParentRow) {
    var compIdLength = rowId.length;
    var matchedArray = [];
    var sortedMatchedArray = [];
    var latestCompId = "";

    if (compIdLength > 1) {
      var parentId = isParentRow ? rowId.slice(0, rowId.length - 1) : rowId;
      if (!isParentRow) {
        matchedArray = _.filter($scope.componentList, function(row) {
          return ((row.rowId.length >= compIdLength) && row.rowId.startsWith(parentId));
        });
      } else {
        matchedArray = _.filter($scope.componentList, function(row) {
          return ((row.rowId.length === compIdLength) && row.rowId.startsWith(parentId));
        });
      }

      sortedMatchedArray = matchedArray.sort();
      latestCompId = sortedMatchedArray[sortedMatchedArray.length - 1].rowId;
      return isParentRow ? getLastChar(latestCompId) : latestCompId;
    } else {
      matchedArray = _.filter($scope.componentList, function(row) {
        return (row.rowId.length === compIdLength || (!isParentRow && row.rowId.startsWith(rowId)));
      });
      sortedMatchedArray = matchedArray.sort();
      latestCompId = sortedMatchedArray[sortedMatchedArray.length - 1].rowId;
      return latestCompId;
    }
  };

  $scope.getWidth = function(rowId) {
    var componentIdLength = rowId && rowId.length ? rowId.length : 0;
    var widthValue = (120 - (componentIdLength * 10));
    widthValue = widthValue ? widthValue : 10;
    return {
      'width': widthValue + 'px'
    };
  }
  $scope.removeRow = function(rowId) {
    if ($scope.componentList && $scope.componentList.length > 1) {
      var newArray = _.filter($scope.componentList, function(arrayItem) {
        return rowId !== arrayItem.rowId;
      });
      $scope.componentList = newArray;
    }
  }

<>你能帮我做这件事吗?< /P>你能考虑添加Spulk/Faldand问题陈述吗?请详细说明我需要用数字来实现ROWID,因为字母表只从A到Z工作。在Z rowid的到来之后,我需要用数字来实现这个功能?你能考虑添加Spulk/Hoople用问题陈述吗?请你详细说明我需要用数字来实现ROWID,因为字母表只从A到Z工作。在Z之后,rowid就像一个特殊的角色。所以我需要用numeri实现这个功能??