Results 1 to 2 of 2
  1. #1
    Gcfotn is offline Member
    Join Date
    Oct 2013
    Posts
    1
    Rep Power
    0

    Default Need some help, Edit Row in google Docs...

    So I have been working with google docs and have created some very surprising things to date and I have one last piece to work out before I can fully implement the various pieces into its greater structure. I need to be able to edit a spreadsheet by its row number, I have found a script in the gallery that allows for this but it does so by using the "Active row". Is there some way to modify it so that it either asks for the row number or selects the row number based off a value in a given cell within the spreadsheet? Thank you in advance!

    Script below (authored by JBchan07@gmail.com / according to the gallery info) *I have sent an email to the original author but no response*)

    function generateMenu() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var menuEntries = [ {name: "Edit Data", functionName: "generateEditDataForm"}];
    ss.addMenu("Edit Form", menuEntries);
    }


    function generateEditDataForm(){
    var mydoc = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = SpreadsheetApp.getActiveSheet();
    var myapp = UiApp.createApplication().setTitle('Edit Data').setHeight('500');
    var scrollPanel = myapp.createScrollPanel().setSize(500, 500);
    var vPanel = myapp.createVerticalPanel();
    // Count of column headings
    ScriptProperties.setProperty('numColumns', sheet.getLastColumn());

    // Active Row
    ScriptProperties.setProperty('activeRow', sheet.getActiveRange().getRowIndex());
    numColumns = ScriptProperties.getProperty('numColumns');
    activeRow = ScriptProperties.getProperty('activeRow');


    var headings = sheet.getRange(1, 1, 1, ScriptProperties.getProperty('numColumns')).getVal ues();
    var activeRowData = sheet.getRange(ScriptProperties.getProperty('activ eRow'), 1, 1, ScriptProperties.getProperty('numColumns')).getVal ues();

    // Creating labels and data fields
    for(i in activeRowData[0]){
    var columnName = 'entry_' + i;
    var label = myapp.createLabel(headings[0][i]).setStyleAttribute("font-weight", "bold");
    if(activeRowData[0][i].length > 256)
    var dataField = myapp.createTextArea().setSize(200, 100).setName(columnName).setId(columnName).setText (activeRowData[0][i]);
    else
    var dataField = myapp.createTextBox().setName(columnName).setId(co lumnName).setText(activeRowData[0][i]);
    // Adding label and field to panel
    vPanel.add(label);
    vPanel.add(dataField);
    }

    // Horizontal panel for 'Edit' and 'Close' button
    var hPanel = myapp.createHorizontalPanel().setHeight(80).setVer ticalAlignment(UiApp.VerticalAlignment.MIDDLE);

    //'Edit' button
    var editButton = myapp.createButton("Edit");
    var editHandler = myapp.createServerHandler('showEditForm');
    editHandler.addCallbackElement(vPanel);
    editButton.addClickHandler(editHandler);

    //'Close' button
    var closeButton = myapp.createButton("Close");
    var closeHandler = myapp.createServerHandler('closeEditForm');
    closeButton.addClickHandler(closeHandler);

    hPanel.add(editButton);
    hPanel.add(closeButton);
    vPanel.add(hPanel);
    scrollPanel.add(vPanel);
    myapp.add(scrollPanel);
    mydoc.show(myapp);
    }


    // Edit form
    function showEditForm(e){
    var sheet = SpreadsheetApp.getActiveSheet();
    var numColumns = ScriptProperties.getProperty('numColumns');
    var activeRow = ScriptProperties.getProperty('activeRow');
    for(i=1; i<=numColumns; i++){
    var columnName = 'entry_' + Math.abs(i-1);
    sheet.getRange(activeRow, i).setValue(e.parameter[columnName]);
    }

    var app = UiApp.getActiveApplication();
    app.close();
    return app;
    }

    // Close form
    function closeEditForm() {
    var app = UiApp.getActiveApplication();
    app.close();
    return app;
    }

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,535
    Blog Entries
    7
    Rep Power
    20

    Default Re: Need some help, Edit Row in google Docs...

    That smells like Javascript, but this is a Java forum ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Replies: 1
    Last Post: 09-22-2012, 06:16 PM
  2. Replies: 2
    Last Post: 02-22-2012, 10:09 AM
  3. Open Ms Word Docs
    By kushagra in forum Advanced Java
    Replies: 13
    Last Post: 02-13-2009, 11:01 AM
  4. JCreator JDK docs?
    By thejerryman in forum JCreator
    Replies: 4
    Last Post: 12-01-2008, 04:31 PM
  5. producing DOCs
    By javaplus in forum New To Java
    Replies: 0
    Last Post: 11-18-2007, 06:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •