jQuery UI Widgets Forums Grid set checkbox value as checked or unchecked based on other column

This topic contains 2 replies, has 2 voices, and was last updated by  sureshatpure 9 years, 3 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author

  • sureshatpure
    Participant

    Hi
    I have a grid with 7 columns, and one is a checkbox type
    I am doing add functionality in the gird
    So while adding a new row is the checkbox column is displayed

     $("#jqxgrid_add").jqxGrid(
                                    {
                                        height: 200,
                                        selectionmode: 'rowselect',
                                        source: dataAdapterAdd,
                                        theme: theme,
                                        editable: true,
                                        columnsresize: true,
                                        columns: [
                                            {text: 'UID', datafield: 'uid', width: 150, cellsalign: 'left', hidden: true},
                                            {text: 'Customer Group', datafield: 'custgroup', width: 100, editable: false},
                                            {text: 'Product Group', datafield: 'itemgroup', width: 150, cellsalign: 'left', editable: false},   
                                            {text: 'Lead id', datafield: 'leadid', displayfield: 'leadid', width: 127, cellsalign: 'center', cellbeginedit:Results.initResultsEditor, initeditor: Results.resultsEditor, cellsrenderer: Results.renderUnits,promptText:'Select Leadid',
                                                            cellvaluechanging: function (row, datafield, columntype, oldvalue, newvalue) 
                                                            {
                                                                //alert("oldvalue "+oldvalue); alert("newvalue "+newvalue);
                                                                  if (newvalue == 0) {
                                                                   return oldvalue;
                                                              } 
    
                                                            }
    
                                              
                                            },
                                                
    
                                            {text: 'noofleads', datafield: 'noofleads', hidden:true, width: 20, cellsalign: 'left', editable: false},
                                            {text: 'result_type', datafield: 'result_type',hidden:false, width: 75, cellsalign: 'left', editable: false},
                                            { text: 'Create Lead', columntype: 'checkbox', datafield: 'create_lead', width: 100, initeditor: Results.resultsEditorChkbox},
                                            {text: 'Activity Type', datafield: 'Sub_Activity', width: 110, cellsalign: 'left', cellbeginedit:Results.initResultsEditorat, initeditor: Results.resultsEditorat, cellsrenderer: Results.renderUnitsat
                                            },
                                            {text: 'Potential', datafield: 'Potential_Quantity', width: 75, cellsalign: 'left', editable: false},
                                            {text: 'Required Quantity', datafield: 'Quantity_Requirement', width: 75, cellsalign: 'left',
                                                cellbeginedit: function (row, datafield, columntype) {
                                                            var rowdata = $("#jqxgrid_add").jqxGrid('getrowdata', row);
                                                            var leadid = rowdata.leadid;
                                                           // alert("leadid in quantity cell rendering "+leadid);
                                                            if(leadid==undefined || leadid==0)
                                                            {
                                                                return true;
                                                            }
                                                            else
                                                            {
                                                                return false;
                                                            }
    
                                                        }
                                            },
                                            {text: 'Sales Type', datafield: 'division', width: 110, cellsalign: 'left',readonly:true,cellbeginedit:Results.initResultsEditorst, initeditor: Results.resultsEditorst, cellsrenderer: Results.renderUnitsst
                                           
                                            },
                                            {text: 'Status', datafield: 'statusid', width: 150, cellsalign: 'center', cellbeginedit:Results.initResultsEditorldst, initeditor: Results.resultsEditorldst, cellsrenderer: Results.renderUnitsldst,promptText:'Select Status',
                                                            cellvaluechanging: function (row, datafield, columntype, oldvalue, newvalue) 
                                                            {
                                                                alert("oldvalue "+oldvalue); alert("newvalue "+newvalue);
                                                              //  alert("datafield "+datafield); 
                                                                  if (newvalue == 0) {
                                                                        return oldvalue;
                                                                    }
                                                                    else if (newvalue!=oldvalue)
                                                                    {
                                                                       $("#jqxgrid_add").jqxGrid('setcellvalue', row, "leadsubstatusid", "Select Substatus");
                                                                        return newvalue;
                                                                    } 
    
                                                            }
    
                                              
                                            },
                                            {text: 'SubStatus', datafield: 'leadsubstatusid', width: 200, cellsalign: 'left',readonly:false,cellbeginedit:Results.initResultsEditorldsubst, initeditor: Results.resultsEditorldsubst, cellsrenderer: Results.renderUnitsldsubst,cellvaluechanging: function (row, datafield, columntype, oldvalue, newvalue) 
                                                        {
                                                           // alert("oldvalue "+oldvalue); alert("newvalue "+newvalue);
                                                              if (newvalue == 0)  {
                                                               return oldvalue;
                                                          } 
                                                           else if (newvalue!=oldvalue)
                                                           {
    
                                                             if(newvalue=='Appointment Fixed')
                                                             {
                                                                
                                                                $("#appiontment_date").val(null);                                       
                                                                $("#popupWindow").jqxWindow('show');
                                                                $("#save_appdt").click(function (event){
                                                                       
                                                                        var date_text = $('#appiontment_date').jqxDateTimeInput('getText');
                                                                        if(date_text=="")
                                                                        {
                                                                            alert("Please select the Appointment Date");
                                                                            return false;
                                                                        }
                                                                        else
                                                                        {
    
                                                                             $("#jqxgrid_add").jqxGrid('setcellvalue', jqxgrid_add_row_index, "appiontmnt_dt",date_text);
                                                                            $("#popupWindow").jqxWindow('close');
                                                                        }
                                                                   
                                                                });
                                                                
                                                             }
                                                             /*Not able to get appointment start*/
                                                              if(newvalue=='Not Able to get the Appointment')
                                                             {
                                                                
                                                                                                      
                                                                $("#popupWindowNot").jqxWindow('show');
                                                                $("#save_na2gappdt").click(function (event){
                                                                
                                                                        var reason_text = $('#not_able_to_get_appointment').val();
                                                                        if(reason_text=="")
                                                                        {
                                                                            alert("Please Enter the Reason");
                                                                            return false;
                                                                        }
                                                                        else
                                                                        {
    
                                                                             $("#jqxgrid_add").jqxGrid('setcellvalue', jqxgrid_add_row_index, "not_able_to_get_appointment",reason_text);
                                                                            $("#popupWindowNot").jqxWindow('close');
                                                                        }
                                                                   
                                                                });
                                                                
                                                             }
                                                             /* Not able to get appointment end*/
                                                             return newvalue;
                                                           }
    
                                                        }
                                           
                                            },
                                            {text: 'Apptmnt Date', datafield: 'appiontmnt_dt', columntype:'datetimeinput', width: 110, align: 'left', cellsformat: 'd',formatString: 'dd/MM/yyyy',readonly:true,editable:false, hidden:false},
    
                                            {text: 'Not Able', datafield: 'not_able_to_get_appointment', width: 110, align: 'left', hidden:true, editable:false},
    
                                            {text: 'Mode of Contact', datafield: 'Mode_Of_Contact', width: 100, cellsalign: 'left', cellbeginedit:Results.initResultsEditorcon, initeditor: Results.resultsEditorcon, cellsrenderer: Results.renderUnitsst
                                            },
                                            {text: 'Time Spent (Hrs)', datafield: 'hour', width: 75, cellsalign: 'left', columntype: 'dropdownlist',
                                                createeditor: function (row, cellvalue, editor) {
                                                    editor.jqxDropDownList({source: ["00 Hr", "01 Hrs", "02 Hrs", "03 Hrs", "04 Hrs", "05 Hrs", "06 Hrs", "07 Hrs", "08 Hrs", "09 Hrs", "10 Hrs"]});
                                                }
                                            },
                                            {text: 'Time Spent (Mins)', datafield: 'minute', width: 75, cellsalign: 'left', columntype: 'dropdownlist',
                                                createeditor: function (row, cellvalue, editor) {
                                                    editor.jqxDropDownList({source: ["0 mins", "5 mins", "10 mins", " 15 mins", "20 mins", "25 mins", "30 mins", " 35 mins", "40 mins", "45 mins", " 50 mins", "55 mins"]});
                                                }
                                            },
                                            {text: 'Notes / Remarks', datafield: 'Notes_Remarks', width: 150, cellsalign: 'left'},
    
                                        ]
    
                                    });
    

    On click on the Lead id , i try to get some values from the database and then based on this is value
    i set the “result_type” column value as “Select” or “Value”, if the result is a “Value” then i want to set the checkbox column “Create Lead” as checked.
    How can i achieve this..?


    Dimitar
    Participant

    Hi sureshatpure,

    Please try this solution:

    $('#jqxgrid_add').on('cellendedit', function (event) {
        // event arguments.
        var args = event.args;
        // column data field.
        var dataField = event.args.datafield;
        // row's bound index.
        var rowBoundIndex = event.args.rowindex;
        // cell value
        var value = args.value;
    
        if (dataField === 'result_type') {
            if (value === 'Select') {
                $("#jqxgrid_add").jqxGrid('setcellvalue', rowBoundIndex, "create_lead", false);
            } else if (value === 'Value') {
                $("#jqxgrid_add").jqxGrid('setcellvalue', rowBoundIndex, "create_lead", true);
            }
        }
    });

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/


    sureshatpure
    Participant

    Thanks Dimitar

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.