Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Chaitanya21

Pages: [1] 2
1
Hi Admin,
Updaterow not working in version 2.2.0 which was working on previous version.

2
Hi admin,

When I add a new row in batch editing version isEditiing($grid) return true. I am facing this issue in the current version(2.2.0) which was not in the previous version.

Code: [Select]
{ "click": function (evt, ui) {
alert("1")
if (isEditing($grid)) {
   return false;
}
alert("2");
                            //append empty row at the end.                           
                            var rowData = { UnitPrice: 0, Discontinued: false }; //empty row
                            var rowIndx = $grid.pqGrid("addRow", { rowData: rowData });
                            $grid.pqGrid("goToPage", { rowIndx: rowIndx });
                            $grid.pqGrid("editFirstCellInRow", { rowIndx: rowIndx });
                        }
Alert 2 will not call.

When I remove isEditing check then new row gets inserted but I had validation in editable function where passed rowData is null.

I am facing issue in the current free version of the grid which was not in the previous version.
Please reply.
 

3
Hi Admin,

I am just close to achieving my target. but still struggling to render brow button with clone object.
When user click/select file then I am cloning the object and storing in rowData.file attribute.
At a time of rendering brows button, i checking whether ui.cellData is empty or not.
If not then iIam trying to attach my clone object. but not working.
When I try to set this clone object to componet outside of grid, it working but not working in render method.
It because render method needs to return a string.

http://jsfiddle.net/Dalvi1988/vgjeodxc/

4
Hi,

I managed to send grid data and attachment to server.(will update code later for referece to others after completing functionality)
But still facing the issue on file input component.

When we click on add button, grid gets refresh. that time File Input component becomes empty.
I know that File Input component is very sensitive so that we can not assign value to that but we can make copy of that.
so my question are:

1. Can we get rendered components back so that we can make copy of that component?

2. can we restrict that particular column from refreshing so that File input button won't lost its data.

Or any other solution? or File input wont work with grid.

Please reply.

5
Hi Admin,

I have not worked on file upload. Please help me to complete my code.

Code: [Select]
var arrayData="";
$(function () {
   


    //called when accept changes button is clicked.
    function acceptChanges() {
        //attempt to save editing cell.
        //debugger;
        if (grid.saveEditCell() === false) {
            return false;
        }

        var isDirty = grid.isDirty();
        if (isDirty) {
            //validate the new added rows.               
            var addList = grid.getChanges().addList;
            for (var i = 0; i < addList.length; i++) {
                var rowData = addList[i];
                var isValid = grid.isValid({ "rowData": rowData }).valid;
                if (!isValid) {
                    return;
                }
            }
            var changes = grid.getChanges({ format: "byVal" });
alert(JSON.stringify(changes))
            //post changes to server
            $.ajax({
                dataType: "json",
                type: "POST",
                async: true,
                beforeSend: function (jqXHR, settings) {
                    grid.showLoading();
                },
                url: "/ExpenseManagement/saveExpense", //for ASP.NET, java                                               
                data: { list: JSON.stringify(changes) },
                processData : false,
                contentType : false,
                success: function (changes) {
                    //debugger;
                    grid.commit({ type: 'add', rows: changes.addList });
                    grid.commit({ type: 'update', rows: changes.updateList });
                    grid.commit({ type: 'delete', rows: changes.deleteList });

                },
                complete: function () {
                    grid.hideLoading();
                }
            });
        }
    }
    var obj = {
        width: 700,
        height: 400,
        wrap: false,
        hwrap: false,
        resizable: true,
        rowBorders: false,
        numberCell: { show: false },
        track: true, //to turn on the track changes.
        flexHeight: true,
        toolbar: {
            items: [
                { type: 'button', icon: 'ui-icon-plus', label: 'New Product', listeners: [
                    { "click": function (evt, ui) {
                        //append empty row at the end.                           
                        var rowData = { UnitPrice: 0, Discontinued: false }; //empty row
                        var rowIndx = $grid.pqGrid("addRow", { rowData: rowData });
                        $grid.pqGrid("goToPage", { rowIndx: rowIndx });
                        $grid.pqGrid("editFirstCellInRow", { rowIndx: rowIndx });
                    }
                    }
                ]
                },
                { type: 'button', icon: 'ui-icon-disk', label: 'Accept Changes', style: 'margin:0px 5px;', listeners: [
                    { "click": function (evt, ui) {
                        acceptChanges();
                    }
                    }
                ]
                },
                { type: 'button', icon: 'ui-icon-cancel', label: 'Reject Changes', listeners: [
                    { "click": function (evt, ui) {
                        $grid.pqGrid("rollback");
                    }
                    }
                ]
                },
                { type: 'separator' },
                { type: 'button', icon: 'ui-icon-cart', label: 'Get Changes', style: 'margin:0px 5px;', listeners: [
                    { "click": function (evt, ui) {
                        var changes = $grid.pqGrid("getChanges");
                        try {
                            console.log(changes);
                        }
                        catch (ex) { }
                        alert("Please see the log of changes in your browser console.");
                    }
                    }
                ]
                }
            ]
        },
        scrollModel: {
            autoFit: true
        },
        selectionModel: {
            type: ''
        },
        cellSave : function (evt, ui) {

        },
        render: function (evt, ui) {

        },
        hoverMode: 'cell',
        editModel: {
            saveKey: $.ui.keyCode.ENTER
        },
        title: "<b>Expense Details</b>",

        colModel: [
            { title: "Expense ID", dataType: "integer", dataIndx: "expenseId", editable: false },
            { title: "Date", width: "100", dataIndx: "date",
        editor: {
            type: 'textbox',
            init: dateEditor
        },
        render: function (ui) {
            var cellData = ui.cellData;
            if (cellData) {
                return $.datepicker.formatDate('yy-mm-dd', new Date(cellData));
            }
            else {
                return "";
            }
        },
        validations: [
                    { type: 'regexp', value: '^[0-9]{2}/[0-9]{2}/[0-9]{4}$', msg: 'Not in mm/dd/yyyy format' }
                ]
    },
            { title: "Location From", width: 140, dataType: "string", align: "right", dataIndx: "fromLocation"},
            { title: "Location To", width: 100, dataType: "String", align: "right", dataIndx: "toLocation"},
            { title: "Description", width: 100, dataType: "String", align: "right", dataIndx: "description"},
            { title: "Amount", width: 100, dataType: "float", align: "right", dataIndx: "amount",
                validations: [{ type: 'gt', value: 0.5, msg: "should be > 0.5"}],
                render: function (ui) {                       
                    var cellData = ui.cellData;
                    if (cellData != null) {
                        return "&#8377;" + parseFloat(ui.cellData).toFixed(2);
                    }
                    else {
                        return "";
                    }
                }
            },

            { title: "Receipt/Document", editable: false, dataIndx: "receipt", minWidth: 200, sortable: false,
            render: function (ui) {
            if(ui.cellData != -1){
                return "<input type='file' name='receipt'/>";
            }
            else return "";
            }
            },
            { title: "", editable: false, minWidth: 83, dataIndx: "delButton", sortable: false, render: function (ui) {
            if(ui.cellData != -1)
                return "<button type='button' class='delete_btn'>Delete</button>";
                else return "";
            }
            }
        ],
        dataModel: {               
            dataType: "JSON",
            location: "remote",
            recIndx: "ProductID",
            url: "/pro/products/get", //for ASP.NET
            //url: "/pro/products.php", //for PHP
            getData: function (response) {
                return { data: response.data };
            }
        },
        //save the cell when cell loses focus.
        quitEditMode: function (evt, ui) {               
            if (evt.keyCode != $.ui.keyCode.ESCAPE) {
                $grid.pqGrid("saveEditCell");
            }
        },
        refresh: function () {
       
       
            $("#grid_editing").find("button.delete_btn").button({ icons: { primary: 'ui-icon-scissors'} })
            .unbind("click")
            .bind("click", function (evt) {
                var $tr = $(this).closest("tr");
                var obj = $grid.pqGrid("getRowIndx", { $tr: $tr });
                var rowIndx = obj.rowIndx;
                $grid.pqGrid("addClass", { rowIndx: rowIndx, cls: 'pq-row-delete' });

                var ans = window.confirm("Are you sure to delete row No " + (rowIndx + 1) + "?");

                if (ans) {
                    $grid.pqGrid("deleteRow", { rowIndx: rowIndx, effect: true, complete: function () {
                        $grid.pqGrid("removeClass", { rowIndx: rowIndx, cls: 'pq-row-delete' });
                    }
                    });
                }
                else {
                    $grid.pqGrid("removeClass", { rowIndx: rowIndx, cls: 'pq-row-delete' });
                }
            });
        },
        cellBeforeSave: function (evt, ui) {
            var isValid = grid.isValid(ui);
            if (!isValid.valid) {
                evt.preventDefault();
                return false;
            }
        }
    };
    var $grid = $("#grid_editing").pqGrid(obj);
   
    //get instance of the grid.
    var grid = $grid.data("paramqueryPqGrid");
});

In this example, i have added <input type="file">.
when I click on Accept changes, list shows all updated, deleted and new data.
how file will be send to server side?

My spring controller:

Code: [Select]
@RequestMapping(value="/saveExpense",method=RequestMethod.POST,consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
        produces = {MediaType.APPLICATION_ATOM_XML_VALUE, MediaType.APPLICATION_JSON_VALUE})
public String saveExpense(@RequestParam String list, @RequestPart("file") MultipartFile file) throws JsonGenerationException, JsonMappingException, IOException{

System.out.println(list);
return "hi";
}

Please can you suggest on my code?

6
Thanks @Ali for your effort,

Finally my controller and Jackson library works.

Below code worked:

Code: [Select]
getUrl: function() {
                        return { url: "/ExpenseManagement/departmentHead", data: "{\"branchId\":"+rowData.branchId+"}" };
                    },


7
Hi Ali,

I have also tried postData attribute. but not working.

When I removed the @requestbody attribute, my controller gets executed. but,
In the case of Get call Jackson converting JSON to Object but in the case of Post call, jackson could not able to convert to Object.
This might be JSON is not getting pass properly.

Normally when I make Post call ajax call from inline grid,
My URL is like: http://localhost:8085/ExpenseManagement/employee?{JSON Parameters}

But when I send Post call from child grid:

My URL is like http://localhost:8085/ExpenseManagement/employee?[here is invalid string]*pq_datatype=Json&_=4398787

I think there is different JSON format to send through the inner grid.

Note: Above Post call URL observe by changing it to "get"



8
Hi ali,

My controller is not accepting JSON which i am passing. I have tried too many combination of string.
@Admin,

The difference between this POST call from DataModel and AJAX call is we using "type" property in ajax and "method" property in data model.
Other than this there is no difference. still why this POST call is not working.
Please help.

9
My child grid data model is like:
Code: [Select]
var gridDetailModel = function( $gridMain, rowData ){
            return {
                height: 130,
                //pageModel: { type: "local", rPP: 5, strRpp: "" },
                dataModel: {
                url: "/ExpenseManagement/departmentHead",
                    location: 'remote',
                   //sorting: 'local',
                    dataType: 'JSON',
                    data: JSON.stringify(jsonToBeSend),
                    async: true,
                     beforeSend: function(xhr,setting) {
                   
                        xhr.setRequestHeader("Accept", "application/json");
                        xhr.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
                    },
                   
                    method: "POST",
                    //contentType:'application/json; charset=UTF-8',
                   
                    error: function () {
                        //$gridMain.pqGrid( 'rowInvalidate', { rowData: rowData });
                    }
                   
                   
                    //url = "/pro/orderdetails.php?orderId=" + orderID //for PHP
                },
                colModel: [
                    { title: "BranchName", width: 80, dataIndx: "branchId" }

        ],
                editable: false,/*
                groupModel: {
                    dataIndx: ["branchId"],
                    dir: ["up"],
                    title: ["{0} - {1} product(s)"],
                    icon: [["ui-icon-triangle-1-se", "ui-icon-triangle-1-e"]]
                },       */         
                flexHeight: true,
                flexWidth: true,
                numberCell: { show: false },
                title: "Order Details",
                showTop: false,
                showBottom: false
            };

JSON data:

Code: [Select]
/*  var jsonToBeSend=new Object();
        jsonToBeSend["id"] = 1;
        jsonToBeSend["success"] = true;
        jsonToBeSend["message"] = "ghgj";  */
       /*  var jsonToBeSend="{\"data\":{\"id\":1}}"; */
        var jsonToBeSend={"id":1};

I tried all the combination of JSON.

I getting below error:
Code: [Select]
11:38:46.051 DEBUG o.s.w.s.m.s.DefaultHandlerExceptionResolver - Resolving exception from handler [public java.util.List<com.chaitanya.departmentHead.model.DepartmentHeadDTO> com.chaitanya.web.controller.DepartmentHeadController.getDepartmentHead(com.chaitanya.ajax.AjaxResponse)]: org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Unrecognized token 'pq_datatype': was expecting ('true', 'false' or 'null')
 at [Source: java.io.PushbackInputStream@5af5c788; line: 1, column: 13]; nested exception is com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'pq_datatype': was expecting ('true', 'false' or 'null')
 at [Source: java.io.PushbackInputStream@5af5c788; line: 1, column: 13]

Controller:
Code: [Select]
@RequestMapping(value="/departmentHead",method=RequestMethod.POST,headers = "Accept=application/json", produces = "application/json")
public @ResponseBody List<DepartmentHeadDTO> getDepartmentHead(@RequestBody AjaxResponse receivedDepartmentHeadDTO){
List<DepartmentHeadDTO> departmentHeadDTOList = null;
LoginUserDetails user = (LoginUserDetails)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
if(Validation.validateForNullObject(user.getLoginDTO().getEmployeeDTO())){

// departmentHeadDTOList = deptHeadSerrvice.findDepartmentHeadUnderCompany(receivedDepartmentHeadDTO);
}

return departmentHeadDTOList;
}

POJO class:
Code: [Select]
public class AjaxResponse {

Long id;
boolean success;
     String message;
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}

}

Please help. Is there something i am missing in POST call.
Because I able make ajax call in my project from your inline grid.

10
Hi,

I have modified Nested grid example given in demo.

I have Branch List which I have fetching when the page is called.

branch JSON data:
Code: [Select]
var data =[{"createdBy":null,"createdDate":null,"modifiedBy":null,"modifiedDate":null,"status":null,"command":null,"loginDTO":null,"serviceStatus":null,"message":null,"branchId":1,"branchCode":null,"branchName":"brach code1","companyDTO":null},{"createdBy":null,"createdDate":null,"modifiedBy":null,"modifiedDate":null,"status":null,"command":null,"loginDTO":null,"serviceStatus":null,"message":null,"branchId":3,"branchCode":null,"branchName":"brach code3","companyDTO":null},{"createdBy":null,"createdDate":null,"modifiedBy":null,"modifiedDate":null,"status":null,"command":null,"loginDTO":null,"serviceStatus":null,"message":null,"branchId":4,"branchCode":null,"branchName":"branch code 4","companyDTO":null}]
On the basis of branch id, I m fetching department and their manager name in child grid.


 
Code: [Select]
$(function () {
        var colM = [
            { title: "", minWidth: 27, width: 27, type: "detail", resizable: false, editable:false },
            { title: "Branch Id", dataType: "integer", dataIndx: "branchId", editable: false, width: 80 },
            { title: "Branch Name", width: 100,dataType:"string", dataIndx: "branchName" }
            ];

        var dataModel = {
            location: "local",
            sorting: "local",           
            dataType: "JSON",
            recIndx: "branchId",
            data: data,
        }

        var $gridMain = $("div#grid_md").pqGrid({
            width: 860, height: 500,
            dataModel: dataModel,
            virtualX: true, virtualY: true,
            editable: false,
            colModel: colM,
            wrap: false,
            hwrap: false,           
            numberCell: { show: false },
            title: "<b>Shipping Orders</b>",                       
            resizable: true,
            freezeCols: 1,           
            selectionModel: { type: 'cell' },
             detailModel: {
                cache: true,
                collapseIcon: "ui-icon-plus",
                expandIcon: "ui-icon-minus",
                init: function (ui) {
                    alert("here")
                    var rowData = ui.rowData,                       
                        detailobj = gridDetailModel( $(this), rowData ), //get a copy of gridDetailModel                       
                        $grid = $("<div></div>").pqGrid( detailobj ); //init the detail grid.

                    return $grid;
                }
            } 
        });
        /*
         * another grid in detail view.
         * returns a new copy of detailModel every time the function is called.
         * @param $gridMain {jQuery object}: reference to parent grid
         * @param rowData {Plain Object}: row data of parent grid
         */
          var gridDetailModel = function( $gridMain, rowData ){
             return {
                 height: 130,
                 pageModel: { type: "local", rPP: 5, strRpp: "" },
                 dataModel: {
                     location: "remote",
                     sorting: "local",
                     dataType: "json",
                     method: "POST",
                     sortIndx: "branchId",
                     error: function () {
                         $gridMain.pqGrid( 'rowInvalidate', { rowData: rowData });
                     },
                     url: "/ExpenseManagement/getDepartmentHead"
                 },
                 colModel: [
                     { title: "Branch ID", width: 80, dataIndx: "branchId" }
          ],
                 editable: false,
                  groupModel: {
                     dataIndx: ["branchId"],
                     dir: ["up"],
                     title: ["{0} - {1} product(s)"],
                     icon: [["ui-icon-triangle-1-se", "ui-icon-triangle-1-e"]]
                 },               
                 flexHeight: true,
                 flexWidth: true,
                 numberCell: { show: false },
                 title: "Department heads Details",
                 showTop: false,
                 showBottom: false
             };
         };

    });

http://jsfiddle.net/pb5kpred/39/
This link is not working because getting error ,
Uncaught TypeError: Cannot read property 'children' of null in:

Please help.

11
Hi admin.
Please help on above issue.

12
Hi admin,

Thanks for reply..

1. Does searchable textbox support valueIndx & labelIndx?

http://jsfiddle.net/v4zx8tjc/4/

Here i am trying searchable textbox with valueIndx & labelIndx. But list is not populating.

2. If above format not supporting, then here i have searchable textbox with label & value format.
Here i am able to show branch name with render function but when i go to edit mode then searchable textbox showing branch id.

Please check below fiddle link.

http://jsfiddle.net/v4zx8tjc/5/

3. When i access your web site from mobile and click on go to forum menu, it goes to git download link. Actually forum menu hidding behind download link.

Please solve my 1st or 2nd point. i have stuck from last 3 days. Please help.

13
Hello admin,
Please reply

1. how to get hierarchical JSON object into dataindx?

2. I have JSON of Brach list
Code: [Select]
branchList = [{ label:'Mumbai',value:'1'},{ label:'Mumbai2', value:'2'},{ label:'Mumbai3', value:'3'}]Here label is branch name and value is branch id.

Code: [Select]
           { title: "Branch", dataIndx: "branchId", width: 90,
                  editor: {                   
                  type: "textbox",
                          init: autoCompleteEditor,
                          options: branchList,
                          focus: function (ui) {
                          alert("focus")
              }   

                      },
                      render: function (ui) {
                      var options = ui.column.editor.options,
              cellData = ui.cellData;
          for (var i = 0; i < options.length; i++) {
              var option = options[i];
             
              if (option.value == cellData) {
                  return option.label;
              }
          }
          }   
                  },

Here my dataIndx:branchId. values are 1 or 2 or 3
In render function I am able to display branch name of corresponding branch id.
but when i goes to edit mode I m getting branch id. Please see attached snapshot.
After selection of item it is showing branch name.

Please reply.

14
Hi admin,

I have employee JSON list and each employee contain branch details(2nd level hierarchy in JSON)

Code: [Select]
[{"createdBy":null,"createdDate":null,"modifiedBy":null,"modifiedDate":null,"status":true,"command":null,"loginDTO":null,"serviceStatus":null,"message":null,"employeeId":1,"firstName":"Chaitanya","middleName":null,"lastName":"Dalvi","emailId":"[email protected]","gender":"M","branchDTO":{"createdBy":null,"createdDate":null,"modifiedBy":null,"modifiedDate":null,"status":null,"command":null,"loginDTO":null,"serviceStatus":null,"message":null,"branchId":3,"branchCode":null,"branchName":"brach code 3","companyDTO":null}},
{"createdBy":null,"createdDate":null,"modifiedBy":null,"modifiedDate":null,"status":true,"command":null,"loginDTO":null,"serviceStatus":null,"message":null,"employeeId":3,"firstName":"Vinod","middleName":"P.","lastName":"Hollar","emailId":"[email protected]","gender":"M","branchDTO":{"createdBy":null,"createdDate":null,"modifiedBy":null,"modifiedDate":null,"status":null,"command":null,"loginDTO":null,"serviceStatus":null,"message":null,"branchId":3,"branchCode":null,"branchName":"brach code 3","companyDTO":null}}]

Also i have branch Name list with key value pair.

Code: [Select]
var branchList = [{ 'branch code 1':'1'},{'branch code 2':'2'},{'branch code 3':'3'}]
When grid populate i need to show branch name in branch Column in text format which i am achieving using below code:

Code: [Select]
{ title: "Branch", dataIndx: "", width: 90,
                  editor: {
                  type: 'textbox',
                  init: autoCompleteEditor
                },
                render: function (ui) {
              return ""+ui.rowData.branchDTO.branchName;
               },
               validations: [{ type: 'minLen', value: 1, msg: "Required"}]
},

But when i click on edit button, how to display corresponding branch name in searchable textbox?

Code: [Select]
var autoCompleteEditor = function (ui) {
            var $inp = ui.$cell.find("input");

            //initialize the editor
            $inp.autocomplete({
                source: branchList,
                selectItem: { on: true }, //custom option
                highlightText: { on: false }, //custom option
                minLength: 0,
                select: function(event, ui) {
event.preventDefault();
$(this).val(ui.item.label);

}
            }).focus(function () {
                //open the autocomplete upon focus               
                $(this).autocomplete("search", "");
            });
           
        }

Also when click on edit button entire row should be editable. no need to click on individual cell to make it editable.
Please Please Please help me!!  :)



https://jsfiddle.net/Dalvi1988/x796gy5h/


15
Hi admin,

I am using searchable textbox from demo example, https://paramquery.com/demos --> Editor & validation

In that i have modified books values( simple string array to Lable-Value JSON)

var books = [{
    label: 'Abc',
    value: '1'
  }, {
    label: 'Pqr',
    value: '2'
  }, {
    label: 'stv',
    value: '3'
  }];

After selecting any books from drop-down, instead of showing Label it is showing value on UI.

and get value when we make ajax to post data

Please help me!!  :)

https://jsfiddle.net/Dalvi1988/x796gy5h/4/



Pages: [1] 2