views:

58

answers:

1

I have a jgrid and on selectiing and submitting the row I have to submit the for data with that url which contains two date field... How can I bind the values of form and selected row together on submit to server?

Nay help will be appreciated.. Thanks!

Update 1:

    jQuery(".sorder").click(function() {
    var earliestDate = jQuery("input#e").val();
    var latestTimeDate = jQuery("input#e").val();
    var grid = jQuery("#orderPreview");
    var id = grid.jqGrid('getGridParam', 'selrow');
    if (id) {
        var ret = grid.jqGrid('getRowData', id);
    }

    $.ajax( {
        type : "POST",
        url : "/cpsb/internalOrderList.do",
        data : {
            method : "create",
            lpn : ret.licensePlateNumber,
            sku : ret.sku,
            description:ret.description,
            cases:ret.caseQuantity,
            hold:ret.isHeld,
            earliestDate:earliestDate,
            latestTimeDate:latestTimeDate
        }

    });

});
+1  A: 

You can get the data from the grid with

var gridData = jQuery("#orderPreview").getRowData(); // no rowid parameter

then you can use

$.ajax({
    type: "POST",
    url: "/cpsb/internalOrderList.do",
    data: gridData,
    dataType: "json"
});

to send the data at once. Because the data will be send per POST and not per GET you have no URL restriction.

By the way in your code you use

var earliestDate = jQuery("input#e").val();
var latestTimeDate = jQuery("input#e").val();

probably in one of the row the id "e" should be changed.

Oleg
@Oleg ....Yes, one id is wrongly copied from my code...one more thing can I append the earliest time and latestTimeDate value since its in a different form but I have to send those values as well with the row data....Thanks!
paul
@paul: In JavaScript it is extrimly easy to add new property to existing object. Just set there: `gridData.method="create"; gridData.earliestDate=earliestDate; gridData.latestTimeDate=latestTimeDate;`
Oleg
@Oleg can I do like this jQuery(".sorder").click(function() { var earliestDate = jQuery("input#e").val(); var latestTimeDate = jQuery("input#e").val(); var gridData = jQuery("#orderPreview").getRowData(); gridData.method = "create"; gridData.earliestDate=earliestDate; gridData.latestTimeDate=latestTimeDate; $.ajax( { type : "POST", url : "/cpsb/internalOrderList.do", data : gridData, dataType:"json" }); });
paul
@paul: Yes, it is what I mean. You should only fix the problem with the usage "input#e" twice.
Oleg
paul
@paul: What can I say. You should verify all and more better debug all. In general it should work.
Oleg
i debug it again and find that when I am using data:gridData ...on console I am seeing undefine but when i changed to data:{ method:"create", param:gridData} it works and show me the data in my firebug console....I wanna send the row and earliest , latest time together....so that in server side I will have data in param and can count how many rows are coming from client side
paul