Click here to Skip to main content
15,880,132 members
Home / Discussions / Web Development
   

Web Development

 
QuestionAdd or Update Row In Data Table Pin
Kevin Marois24-Apr-17 12:13
professionalKevin Marois24-Apr-17 12:13 
AnswerRe: Add or Update Row In Data Table Pin
Richard Deeming25-Apr-17 12:48
mveRichard Deeming25-Apr-17 12:48 
GeneralRe: Add or Update Row In Data Table Pin
Kevin Marois25-Apr-17 12:49
professionalKevin Marois25-Apr-17 12:49 
GeneralRe: Add or Update Row In Data Table Pin
Kevin Marois26-Apr-17 8:01
professionalKevin Marois26-Apr-17 8:01 
GeneralRe: Add or Update Row In Data Table Pin
Richard Deeming27-Apr-17 1:39
mveRichard Deeming27-Apr-17 1:39 
GeneralRe: Add or Update Row In Data Table Pin
Kevin Marois28-Apr-17 7:21
professionalKevin Marois28-Apr-17 7:21 
GeneralRe: Add or Update Row In Data Table Pin
Richard Deeming28-Apr-17 8:27
mveRichard Deeming28-Apr-17 8:27 
GeneralRe: Add or Update Row In Data Table Pin
Kevin Marois1-May-17 6:55
professionalKevin Marois1-May-17 6:55 
Using what you've taught me, as well as examples like this, I now have this

The Table
I added SPAN tags to the table rows
grid.Column(columnName: "RowId", header: "Row Id",              format: @<text><span data-row-id="@item.RowId">@item.RowId</span></text>),
grid.Column(columnName: "SiteId", header: "Site Id",            format: @<text>@item.SiteId</text>),
grid.Column(columnName: "Instrument", header: "Instrument",     format: @<text>@item.InstrumentId</text> ),
grid.Column(columnName: "TowerLocation", header: "Tower",       format: @<text>@item.TowerLocation</text>),
grid.Column(columnName: "BayLocation", header: "Bay Location",  format: @<text>@item.BayLocation</text>),
grid.Column(columnName: "BaySerialNo", header: "Bay Serial #",  format: @<text>@item.BaySerialNo</text>),
grid.Column(columnName: "BayStatus", header: "Bay Status",      format: @<text>@item.BayStatus</text>),
grid.Column(columnName: "AccessionId", header: "Accession ID",  format: @<text>@item.AccessionId</text>),
grid.Column(columnName: "Result", header: "Result",             format: @<text>@item.Result</text>),
grid.Column(columnName: "AssayName", header: "Assay Name",      format: @<text>@item.AssayName</text>),
grid.Column(columnName: "TestStarted", header: "Started",       format: @<text>@item.Started</text>),
grid.Column(columnName: "TestCompleted", header: "Completed",   format: @<text>@item.Completed</text>),
grid.Column(columnName: "TestSummary", header: "Test Summary",  format: @<text>@item.TestSummary</text> )

The JavaScript Code
// Find the row who's Id matches the model's RowId
var $row = $(".webgrid-table").find("span[data-row-id='" + model.RowId + "']").closest("tr");

// If the row was found...
if ($row.length) {

    // Update the row
    var col01 = $row.find(".x-SiteId").text(model.SiteId);
    var col02 = $row.find(".x-InstrumentId").text(model.InstrumentId);
    var col03 = $row.find(".x-TowerLocation").text(model.TowerLocation);
    var col04 = $row.find(".x-BayLocation").text(model.BayLocation);
    var col05 = $row.find(".x-BaySerialNo").text(model.BaySerialNo);
    var col06 = $row.find(".x-BayStatus").text(model.BayStatus);
    var col07 = $row.find(".x-AccessionId").text(model.AccessionId);
    var col08 = $row.find(".x-Result").text(model.Result);
    var col09 = $row.find(".x-AssayName").text(model.AssayName);
    var col10 = $row.find(".x-Started").text(model.Started);
    var col11 = $row.find(".x-Completed").text(model.Completed);
    var col12 = $row.find(".x-TestSummary").text(model.TestSummary);

}
else {

    // The row does not exist, so add it to the table

    // Make a copy of the first row
    var table = document.getElementById('divData');
    var new_row = table.rows[0].cloneNode(true);
    var len = table.rows.length;
    new_row.cells[0].innerHTML = len;

    // Copy the model's data to the new row
    new_row.cells[1].value = mode.SiteId;
    new_row.cells[2].value = mode.InstrumentId;
    new_row.cells[3].value = mode.TowerLocation;
    new_row.cells[4].value = mode.BayLocation;
    new_row.cells[5].value = mode.BaySerialNo;
    new_row.cells[6].value = mode.BayStatus;
    new_row.cells[7].value = mode.AccessionId;
    new_row.cells[8].value = mode.Result;
    new_row.cells[9].value = mode.AssayName;
    new_row.cells[10].value = mode.Started;
    new_row.cells[11].value = mode.Completed;
    new_row.cells[12].value = mode.TestSummary;

    // Add the new row to the table
    table.appendChild(new_row);
}

Any reason this technique would not work?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.


modified 1-May-17 14:03pm.

GeneralRe: Add or Update Row In Data Table Pin
Richard Deeming3-May-17 9:51
mveRichard Deeming3-May-17 9:51 
GeneralRe: Add or Update Row In Data Table Pin
Kevin Marois3-May-17 10:35
professionalKevin Marois3-May-17 10:35 
GeneralRe: Add or Update Row In Data Table Pin
Kevin Marois3-May-17 10:37
professionalKevin Marois3-May-17 10:37 
QuestionMSChart load at Runtime raise error NullReferenceException System.Web.UI.DataVisualization.Charting.Axis.Resize Pin
lamiaa_moh23-Apr-17 2:06
lamiaa_moh23-Apr-17 2:06 
AnswerRe: MSChart load at Runtime raise error NullReferenceException System.Web.UI.DataVisualization.Charting.Axis.Resize Pin
Afzaal Ahmad Zeeshan23-Apr-17 2:33
professionalAfzaal Ahmad Zeeshan23-Apr-17 2:33 
Questionapprendre à coder facilement Pin
Member 1312801214-Apr-17 0:51
Member 1312801214-Apr-17 0:51 
AnswerRe: apprendre à coder facilement Pin
User 418025416-Apr-17 16:46
User 418025416-Apr-17 16:46 
Questioncookies not storing in login page why???showing NO cookies found Pin
LOKENDRA YADAV7-Apr-17 20:19
LOKENDRA YADAV7-Apr-17 20:19 
AnswerRe: cookies not storing in login page why???showing NO cookies found Pin
Richard Deeming10-Apr-17 7:41
mveRichard Deeming10-Apr-17 7:41 
QuestionShould i use bootstrap for my project? Pin
Member 131100775-Apr-17 23:37
Member 131100775-Apr-17 23:37 
AnswerRe: Should i use bootstrap for my project? Pin
Richard Deeming6-Apr-17 2:06
mveRichard Deeming6-Apr-17 2:06 
GeneralRe: Should i use bootstrap for my project? Pin
Member 131100776-Apr-17 7:35
Member 131100776-Apr-17 7:35 
GeneralRe: Should i use bootstrap for my project? Pin
Richard Deeming6-Apr-17 7:41
mveRichard Deeming6-Apr-17 7:41 
QuestionMVC PHP Pin
Member 115700245-Apr-17 22:51
Member 115700245-Apr-17 22:51 
AnswerRe: MVC PHP Pin
Jochen Arndt5-Apr-17 23:10
professionalJochen Arndt5-Apr-17 23:10 
AnswerRe: MVC PHP Pin
ZurdoDev6-Apr-17 2:05
professionalZurdoDev6-Apr-17 2:05 
Questionweb development MVC Codeignatir Pin
Member 115700245-Apr-17 22:49
Member 115700245-Apr-17 22:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.