We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Loading header from left to right in a header then dynamically adding text after generated table.

I've been able to follow along w/ the documentation so far but I haven't seen anything pertaining the solution I need. Basically, I fill a viewbag w/ header titles but the amount of headers is going to vary. So I'm looking for some way to 1. Load those headers from left to right starting at cell B5 (instead of filling a column up to down, fill a row left to right). Then after that I have an idea for what I'd like to do but was hoping that this may already exist w/ SyncFusion controls: Whether that information loaded 5, 20, or 25 cells I'd need (considering doing a count and alphabet compare) the code to dynamically know to add data to a cell after the last one in that group I previously mentioned. Say the data loads from B5 to V5, I'd then need a dynamic way to recognize this instead of hardcoding it to display data in cell W5 because other parameters might dictate that for another only B5 to N5 may be filled (in this case I'd need cell O5 to populate with what W5 in the previous example would have. I can provide more detail if needed.

1 Reply

SI Silambarasan I Syncfusion Team July 14, 2017 01:00 PM UTC

Hi Jacob, 
 
Thank you for using Syncfusion products. 
 
We have checked your requirement and it has been achieved by using ‘updateRange()’ & ‘updateCellValue()’ client-side method to update a range of cells or single cell. Please refer the below code example. 
 
 
$(function () { 
    $("#Spreadsheet").ejSpreadsheet({ 
             columnWidth: 90, 
             loadComplete: "onLoadComplete" 
       }); 
 
    $("#updateCellValElem").bind("click", function () { 
        var ssObj = $("#Spreadsheet").data("ejSpreadsheet"), cellAddr = $("#cellAddrElem").val(), cellValue = $("#cellValueElem").val(); 
        ssObj.XLEdit.updateCellValue({ rowIndex: ssObj.getRangeIndices(cellAddr)[0], colIndex: ssObj.getRangeIndices(cellAddr)[1] }, cellValue); 
    }); 
}); 
              
function onLoadComplete(args) { 
       var settings = { dataSource: dataSource, showHeader: true, startCell: "A1" }; 
 
    // To update range of cells with the specified settings  
    this.updateRange(1, settings); // 1 => Sheet Index                     
       settings = { dataSource: newDataSource, showHeader: false, startCell: "A13" }; 
 
    // To update range of cells with the specified settings  
    this.updateRange(1, settings); // 1 => Sheet Index                     
} 
 
 
<table> 
    <tr> 
        <td>Enter the cell address & value to update:</td> 
        <td> 
            <input type="text" id="cellAddrElem" value="A2" /></td> 
        <td> 
            <input type="text" id="cellValueElem" value="TEST" /></td> 
        <td> 
            <button id="updateCellValElem">Update it</button> 
        </td> 
    </tr> 
</table> 
//... 
    <div id="Spreadsheet"></div> 
 
 
 
Sample Link:  
 
Please refer the below help documentation links for more details, 
 
Could you please check the above sample and get back to us if we misunderstood your requirement? 
 
Regards, 
Silambarasan 


Loader.
Live Chat Icon For mobile
Up arrow icon