Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
setRowData updating all newly added rows in the grid
18/12/2013
07:44
Avatar
sathish.adabala
Member
Members
Forum Posts: 3
Member Since:
14/12/2013
sp_UserOfflineSmall Offline

hi ,

i am adding row in button click using the addDatatRow with some default data. after that i am editing this data with some other data. i need the requirement like need to drag data from the above cells to below cells like in excel. for this i am adding the row with default data later draging the above cell data into the below cells. when i am editing these newly added rows if i am changed one cell in the row that is effecting to the all the rows for that cell. can any one help on this????

i have this issue in IE10 only. in IE8, mozila, crome it is working.

 <script type="text/javascript">
        var lastsel2;
        //jQuery("#editgrid").jqGrid({
        $(function () {
            $("#editgrid").jqGrid({
                url: 'WebForm5.aspx?q=1', datatype: "json", mtype: "POST",
                colNames: ['Inv No', 'Date', 'Client', 'Amount', 'Tax', 'Total', 'Closed', 'Ship via', 'Notes'],
                colModel: [{ name: 'id', index: 'id', width: 55, editable: false, editoptions: { readonly: true, size: 10 } },
                { name: 'invdate', index: 'invdate', width: 80, editable: true, editoptions: { size: 10 } },
                 { name: 'name', index: 'name', width: 90, editable: true, editoptions: { size: 25 } },
                  { name: 'amount', index: 'amount', width: 60, align: "right", editable: true, editoptions: { size: 10 } },
                  { name: 'tax', index: 'tax', width: 60, align: "right", editable: true, editoptions: { size: 10 } },
                  { name: 'total', index: 'total', width: 60, align: "right", editable: true, editoptions: { size: 10 } },
                  { name: 'closed', index: 'closed', width: 55, align: 'center', editable: true, edittype: "checkbox", editoptions: { value: "true:false" } },

                  { name: 'ship_via', index: 'ship_via', width: 70, editable: true, edittype: "select", editoptions: { value: "FE:FedEx;TN:TNT" } },
                   { name: 'note', index: 'note', width: 100, sortable: false, editable: true, edittype: "textarea", editoptions: { rows: "2", cols: "20" } }],
                rowNum: 10, rowList: [10, 20, 30],
                jsonReader: {
                    page: "page",
                    total: "total",
                    records: "records",
                    root: "rows",
                    repeatitems: false
                },
                onSelectRow: function (id) {
                    if (id && id !== lastsel2) {
                        jQuery('#editgrid').jqGrid('restoreRow', lastsel2);
                        jQuery('#editgrid').jqGrid('editRow', id, true);
                        lastsel2 = id;
                    }
                },
                pager: '#pagered',
                sortname: 'id',
                viewrecords: true,
                sortorder: "desc",
                caption: "Search Example",
                hidegrid: false,
                loadonce: true,
                cellEdit: true,
                cellsubmit: 'clientArray',
                afterEditCell: function (id, name, val, iRow, iCol) {
                   if (name == 'invdate') { jQuery("#" + iRow + "_invdate", "#celltbl").datepicker({ dateFormat: "yy-mm-dd" }); }
                },
                afterSaveCell: function (rowid, name, val, iRow, iCol) {
                    if (name == 'name') {
                        var Name = jQuery("#editgrid").jqGrid('getCell', iRow-1, iCol+1 );
                        jQuery("#editgrid").jqGrid('setRowData', iRow-1, Name);
                    }
                    if (name == 'amount') {
                        var Gender = jQuery("#editgrid").jqGrid('getCell', iRow-1, iCol – 1);
                        jQuery("#editgrid").jqGrid('setRowData', iRow-1, Gender);
                    }
                },
                editurl: "WebForm5.aspx/UpdatePerson"
            });
            jQuery("#editgrid").navGrid('#pagered', {
                edit: true, add: true, del: true, search: true,editheight:800
            })
            jQuery("#keynav").jqGrid('navGrid', '#pkeynav', { edit: false, add: false, del: false });

        });
        $("#bedata").click(function () { jQuery("#editgrid").jqGrid('editGridRow', "new", { height: 280, reloadAfterSubmit: false }); });

        $("#sendButton").click(function () {
            var gridData = jQuery("#editgrid").getRowData();
            var postData = JSON.stringify(gridData);
            alert("JSON serialized jqGrid data:n" + postData);
            $.ajax({
                type: "POST",
                url: "WebForm5.aspx?p=1″,
                data: postData,
                dataType: "json",
                contentType: "application/json; charset=utf-8″,
                success: function (response, textStatus, xhr) {
                    alert("success");
                },
                error: function (xhr, textStatus, errorThrown) {
                    alert(errorThrown);
                }
            });
        });

        $("#btnSendToSever").click(function () {
            var gridData = jQuery("#editgrid").getRowData();
            debugger;
            var postData = JSON.stringify(gridData);
            var data1 = '{"Data":' + postData + '}';
           // alert("JSON serialized jqGrid data:n" + postData);
            $.ajax({
                type: "POST",
                url: "WebForm5.aspx/SendDataToServer",
                data : data1,
                dataType: "json",
                contentType: "application/json; charset=utf-8″,
                success: function (result) {
                    alert("Sucess-2″);
                },
                error: function () {
                    alert("Failed");
                }
            });
        });

        function postMethod() {
            debugger;
           var text = 'value';
            var jsonText = JSON.stringify({ name: text });
            $.ajax({
                type: "POST",
                url: "WebForm5.aspx/SendDataToServer1″,
                contentType: "application/json; charset=utf-8″,
                data: jsonText,
                dataType: "json",
                success: function (response) {
                    var person = response.d;
                    alert(person.Name);
                }
            });
        }
       
        $("#button2″).click(function () {
            
            var recordcount1 = $("#editgrid").getGridParam("records");
            var datarow = [{ "id": recordcount1 + 1, "invdate": "12/13/2013", "name": "test", "amount": "1000", "tax": "200", "total": "50000", "closed": "true", "ship_via": "fedex", "note": "aljaldfjladf" }];
            $("#editgrid").addRowData(recordcount1 + 1,datarow, "last");

        });

         </script>

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
25 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information