insertSeries (index, seriesCount, addExpander, callback);
index. Series insert position.
seriesCount. Number of inserted series.
addExpander. Indicates whether to add an expander for the row.
callback. Handler that processes operation execution end.
The insertSeries method inserts a row into the table.
To execute the example, the page must contain the WorkbookBox component named workbookBox (see Example of Creating the WorkbookBox Component), and also add the following code in the handler, that processes document opening event:
// Create an instance of the button class var series; var btnInsertSerie = new PP.Ui.Button({ ParentNode: document.body, //DOM parent node Content: "Add row", //text Click: PP.Delegate(insertSrs) }); var lanerbox = workbookBox.getDataView().getGridView(); function insertSrs() { var source = wbk;//Return an instance of the PP.TS.WbkDocument class //Create an object that is passed as parameters to the getAddSeriesSettings method series = []; var serie = {}; //Set series key serie.k = "0"; //Set series identifier serie.id = ""; //Set series name in the language corresponding to the current locale serie.n = PP.resourceManager.getString("WbkNewSerie") + " " + tsService._NewSeriesCount; //Iterate series counter in the workbook tsService._NewSeriesCount++; //Set series visibility serie.vis = True; //Set series type serie.kind = "Source"; //Set series tooltip serie.hint = ""; //Set series formula serie.calc = {}; //Get and set series index serie.index = tsService._getMaxNonChildSerieIndex(wbk) + 1; if (source.getWbkMetadata().rubrs.def) serie.calc.rubKey = source.getWbkMetadata().rubrs.def.k; else serie.calc.rubKey = source.getHier().getMetadata().obInst.obDesc.k; series.push(serie); serie.atts = { its: { it: []} }; serie.level = "Month"; //Get body of request for adding series to workbook var body = tsService.getAddSeriesSettings(source, series, True); wbk.setIsChanged(True); tsService._invokeRemoteProc(source, body, function(sender, args) { //Insert row to table lanerbox.insertSeries(0); }); removeSeriesButt.setEnabled(True); btnInsertSerie.setEnabled(False); } var removeSeriesButt = new PP.Ui.Button({ ParentNode: document.body, //DOM parent node Content: "Remove last row", //Label Click: PP.Delegate(onClickRemoveSeries), Enabled: False }); function onClickRemoveSeries() { var wbk = args.Workbook; //Get last series var serie = [wbk.getActiveSheet().getSeries()[wbk.getActiveSheet().getSeries().length - 1]]; //Remove last series from workbook tsService.removeSeries(wbk, serie, PP.Delegate(onResponse)); function onResponse(sender, args) { var seriesTabSheetIndexes = [3]; var meta = JSON.parse(args.ResponseText); //Remove series from table lanerbox.removeSeries(serie, seriesTabSheetIndexes, meta); } removeSeriesButt.setEnabled(False); btnInsertSerie.setEnabled(True); }
After executing the example the Add Row and Delete the Last Row button are added to the HTML page. Clicking the Add Row button adds a new row in the table, clicking the Delete the Last Row button removes the last row.
See also: