Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why this code is not executing?
Message
General information
Forum:
ASP.NET
Category:
MVC
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01555962
Message ID:
01556339
Views:
46
document.location works nice, but what I really want is to be able to grab the row data, but open the form the same way it was opened before (e.g. in modal window).

Here is what I currently have:
function edit(com, grid)
{
        $('.trSelected', grid).each(function () {

          
                var id = $(this).attr('id');
                id = id.substring(id.lastIndexOf('row') + 3);

                document.location = '/Client/Edit/' + id;            

            $("#sform").dialog({
                autoOpen: false,
                show: "blind",
                width: 1000,
                height: 600
            });
            $("#sform").dialog("open");
            clearForm();
            $('#fntype').val('Edit');
            $('#Id').val($('.trSelected td:eq(0)').text());
            $('#Number').val($('.trSelected td:eq(1)').text());
            $('#Name').val($('.trSelected td:eq(2)').text());

            $('#Contact1').val($('.trSelected td:eq(3)').text());

        });

    }
I can not figure out certain things:

1. I need to get the row data from the server, but then continue with the rest of the code (e.g. show the info in that modal form)

2. How to make double click work

3. Why my validations no longer fire after I re-factored the class. I want to use complex types, but with the complex types I get
<div class="editor-label">
    <label for="Email">Email</label>
</div>
<div class="editor-field">
    <input class="text-box single-line" data-bind="value: Email" data-val="true" 
data-val-email="The Email field is not a valid e-mail address." 
data-val-length="The field Email must be a string with a maximum length of 100." data-val-length-max="100"
 id="Email" name="Contact1.Email" type="text" value="" />
    <span class="field-validation-valid" data-valmsg-for="Email" data-valmsg-replace="true"></span>
</div>
So, the id is "Email" and the name is "Contact1.Email"

I have two controls with the same Id in the form and this is why I think validations are getting confused. However, I don't know what to do to fix the problem?






>>
>>Can you please show a sample of the client side redirect? Also, how will it get the model I am passing?
>
>I tend to just use something like this:
>
>
>document.location = "urlgoeshere";
>
>
>You don't really pass the model directly. What I do is embed the primary key in a hidden column of the grid. When the grid loads, I check the record count. If it's 1 I grab this hidden column and include it in my redirect.
>
>Here's some code from one of my projects. I'm using jqGrid so you won't be able to use it as-is, but hopefully it helps point you in the right direction:
>
>Basically what happens is the grid requests data via JSON (not shown). Once it has retrieved that data it calls gridLoadComplete and passes in the data it received. I select the first row. Another jqGrid event fires when the row is selected that calls selectLoan and it passes in the primary key I set in gridLoadComplete. I have a settings object that holds my settings and URLs so I take that URL and add in the ID (so the URL ends up being something like /Controller/Action/Edit/1)
>
>Most of this code is just eventing stuff specific to jqGrid.
>
>
>   var settings = {
>      viewLoanUrl: "@Url.Content("~/Loan/Detail/")";
>   };
>
>    function selectLoan(id, selected) {
>        document.location = settings.viewLoanUrl + id;
>    }
>
>    function gridLoadComplete(data) {
>        if (data.records == "1") {
>            var items = $("#loan").jqGrid("getRowData");
>            $("#loan").jqGrid("setSelection", items[0].Loan);            
>        }
>    }
>
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform