Click here to Skip to main content
15,918,617 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: Layout Elements Horizontally Pin
Richard Deeming10-May-17 5:35
mveRichard Deeming10-May-17 5:35 
GeneralRe: Layout Elements Horizontally Pin
Kevin Marois10-May-17 5:40
professionalKevin Marois10-May-17 5:40 
GeneralRe: Layout Elements Horizontally Pin
MikeSpock2-Jun-17 0:38
professionalMikeSpock2-Jun-17 0:38 
QuestionChange WebGrid RowsPerPage During Runtime Pin
Kevin Marois9-May-17 11:43
professionalKevin Marois9-May-17 11:43 
AnswerRe: Change WebGrid RowsPerPage During Runtime Pin
Richard Deeming10-May-17 1:38
mveRichard Deeming10-May-17 1:38 
GeneralRe: Change WebGrid RowsPerPage During Runtime Pin
Kevin Marois10-May-17 6:27
professionalKevin Marois10-May-17 6:27 
JokeRe: Change WebGrid RowsPerPage During Runtime Pin
Richard Deeming10-May-17 7:04
mveRichard Deeming10-May-17 7:04 
QuestionReload WebGrid From Controller Pin
Kevin Marois9-May-17 11:08
professionalKevin Marois9-May-17 11:08 
AnswerRe: Reload WebGrid From Controller Pin
Richard Deeming10-May-17 1:04
mveRichard Deeming10-May-17 1:04 
GeneralRe: Reload WebGrid From Controller Pin
Kevin Marois10-May-17 5:55
professionalKevin Marois10-May-17 5:55 
GeneralRe: Reload WebGrid From Controller Pin
Richard Deeming10-May-17 6:08
mveRichard Deeming10-May-17 6:08 
QuestionWebGrid Searching and Filtering Pin
Kevin Marois8-May-17 8:25
professionalKevin Marois8-May-17 8:25 
SuggestionRe: WebGrid Searching and Filtering Pin
Richard Deeming8-May-17 8:45
mveRichard Deeming8-May-17 8:45 
GeneralRe: WebGrid Searching and Filtering Pin
Kevin Marois8-May-17 10:41
professionalKevin Marois8-May-17 10:41 
QuestionMy website inner pages are not crawling and indexed? Pin
Bharathi Karampudi6-May-17 0:26
Bharathi Karampudi6-May-17 0:26 
AnswerRe: My website inner pages are not crawling and indexed? Pin
Richard Andrew x646-May-17 5:35
professionalRichard Andrew x646-May-17 5:35 
GeneralRe: My website inner pages are not crawling and indexed? Pin
Bharathi Karampudi7-May-17 18:04
Bharathi Karampudi7-May-17 18:04 
QuestionRefresh WebGrid Pin
Kevin Marois2-May-17 11:39
professionalKevin Marois2-May-17 11:39 
SuggestionRe: Refresh WebGrid Pin
Richard Deeming3-May-17 10:52
mveRichard Deeming3-May-17 10:52 
GeneralRe: Refresh WebGrid Pin
Kevin Marois3-May-17 10:54
professionalKevin Marois3-May-17 10:54 
GeneralRe: Refresh WebGrid Pin
Richard Deeming3-May-17 11:03
mveRichard Deeming3-May-17 11:03 
GeneralRe: Refresh WebGrid Pin
Kevin Marois3-May-17 12:31
professionalKevin Marois3-May-17 12:31 
GeneralRe: Refresh WebGrid Pin
Richard Deeming4-May-17 0:47
mveRichard Deeming4-May-17 0:47 
GeneralRe: Refresh WebGrid Pin
Kevin Marois4-May-17 7:11
professionalKevin Marois4-May-17 7:11 
GeneralRe: Refresh WebGrid Pin
Richard Deeming4-May-17 7:32
mveRichard Deeming4-May-17 7:32 
Kevin Marois wrote:
.find("span[x-RowId='" + model.RowId + "']")
...
$row.find("span[x-RowId]").data("rowId", model.RowId)

That's a bit confusing - you're looking for an attribute called x-RowId, but you're updating the data-row-id attribute. It would probably be better to stick with the data-row-id attribute, since that's the standard way of associating extra data with an element.

There's also no need to update the row ID for an existing row.
JavaScript
proxy.on('notifyAllClientsOfChanges', function (model) {
    
    console.log("notifyAllClientsOfChanges called");
    
    var $row = $(".webgrid-table").find("span[data-row-id='" + model.RowId + "']").closest("tr");
    console.log(model.RowId, $row);
    
    if (!$row.length) {
    
        var table = document.getElementById('MyGrid');
        console.log("TABLE", table);
        
        var len = table.rows.length;
        console.log("len = ", len);
        
        var new_row = table.rows[1].cloneNode(true);
        console.log("new_row", new_row);
        
        new_row = table.tBodies[0].appendChild(new_row);
        console.log("new_row", new_row);
        
        $row = $(new_row);
        $row.find("span[data-row-id]").data("rowId", model.RowId).text(model.RowId);
    }
    
    console.log("SETTING ROW VALUES");
    
    $row.find(".x-SiteId").text(model.SiteId);
    $row.find(".x-InstrumentId").text(model.InstrumentId);
    $row.find(".x-TowerLocation").text(model.TowerLocation);
    $row.find(".x-BayLocation").text(model.BayLocation);
    $row.find(".x-BaySerialNo").text(model.BaySerialNo);
    $row.find(".x-BayStatus").text(model.BayStatus);
    $row.find(".x-AccessionId").text(model.AccessionId);
    $row.find(".x-Result").text(model.Result);
    $row.find(".x-AssayName").text(model.AssayName);
    $row.find(".x-Started").text(model.Started);
    $row.find(".x-Completed").text(model.Completed);
    $row.find(".x-TestSummary").text(model.TestSummary);
    
    console.log("DONE");
}

It looks like the server is sending 0 as the RowId, so you'd need to fix that on the server.

The appendChild method will always insert the element at the end of the specified parent. If you want to insert it at a specific position, you'll need to find the row that should immediately follow it, and use insertBefore[^] to add the node. Something like this:
JavaScript
var new_row = table.rows[1].cloneNode(true);
console.log("new_row", new_row);

var before_row = null;
var before_value = null;

$(".webgrid-table tr").each(function(){
    var value = $(this).find(".x-Started").text();
    
    // TODO: Convert the value to an appropriate type for sorting if necessary:
    if (value < model.Started) {
        if (!before_row || before_value < value) {
            before_row = this;
            before_value = value;
        }
    }
});

if (before_row) {
    new_row = table.tBodies[0].insertBefore(new_row, before_row);
}
else {
    new_row = table.tBodies[0].appendChild(new_row);
}

console.log("new_row", new_row);

If you can't convert the text value of the x-Started span to an appropriate type for sorting, you'll need to use another data- attribute to store and retrieve a sortable value.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


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.