0

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
        }

    });

});
paul
  • 1,124
  • 9
  • 27
  • 45
  • How you make "submitting the row"? Are the selected row in the inline editing mode and you want save it? – Oleg Sep 27 '10 at 20:35
  • @Oleg my application is like shopping cart where I add rows frm a different grid ...than I need to send all rows from that grid (with addition to that latest time and earliest time from there...my approach is updated in my question – paul Sep 28 '10 at 14:16
  • I am adding the value from those input like this way var earliestDate = jQuery("input#e").val(); var latestTimeDate = jQuery("input#e").val(); but problem is that from orderPreview grid I have to submit all rows without have to select + need to send those dates(earliest,latesttimedate)...another problem is that appending so many data with url is a problem ..how server side code will know how many rows were sending.. – paul Sep 28 '10 at 14:21

1 Answers1

1

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
  • 220,925
  • 34
  • 403
  • 798
  • @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 Sep 28 '10 at 15:35
  • @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 Sep 28 '10 at 16:01
  • @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 Sep 28 '10 at 16:23
  • @paul: Yes, it is what I mean. You should only fix the problem with the usage "input#e" twice. – Oleg Sep 28 '10 at 16:26
  • when I am trying to send those rows ..I saw &undefine=undefine&undefine=undefine&undefine=undefine....not sure why its shoqing that – paul Sep 28 '10 at 16:34
  • @paul: What can I say. You should verify all and more better debug all. In general it should work. – Oleg Sep 28 '10 at 16:52
  • 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 Sep 28 '10 at 19:30