javascript - How to increase Column value with Numeric -
i have implemented below component rowid alphabets, need change numberic. in component have implemented there column called rowid, rowid increase when click on +
button, if press on ++
parent rowid+starts starting alphabet. following component have implemented.mycomponent.
i need implement rowid numberic because alphabets working z only,after z rowid coming special charecters.so need implement functionality numeric.so overcome problem.
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; } }
can please me this.
Comments
Post a Comment