jQuery UI Widgets Forums Grid probleme with wrong getcellvalue if I click on another editing value.

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

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

  • nico86
    Participant

    Hi,
    I need help,
    When i modified one cell of my grid I want to get value editing to sent it with a ajax request.

    firstly I change the value of my status field, then

    if I click outside the grid or if I did [ENTER] then id which I need are ok because rowIndex is good.
    But if I click on another editable cell (another line), rowIndex will not be good because it will take the number of the new clicked line

    example :
    if I change the value of the status field on line 1 and then I click on [ENTER]or outside the grid then everything is ok .

    But if I change the value of the status field on line 1 and then I click the field status of the line 5 will then rowIndex 4 (instead of 0), and send my values ​​to my request will be wrong.

    how to recover the right value ? should start the getcellvalue when I click on the cell instead of placing it in the validation part ? or block the ability of clicks an editable fields as I didn ‘t enter or click outside the grid

    Thanks for your help and sorry for my english.

    here below my code

    columns: [
    { text: 'PATIDENT', datafield: 'PATIDENT', width: 100, editable: false },
    { text: 'ADRNBA', datafield: 'ADRNBA', width: 60, editable: false },
    { text: 'SPLIT', datafield: 'ROWSPLIT', width: 50, editable: false },
    { text: 'DETECT_DATE', datafield: 'DETECT_DATETIMEC', width: 100, editable: false },
    { text: 'DISCOM', datafield: 'DISCOM', width: 150, editable: false },
    { text: 'DLLTCOD', datafield: 'DLLTCODC', width: 150, editable: false },
    { text: 'DPTCOD', datafield: 'DPTCODC', width: 150, editable: false },
    { text: 'STARTDAT', datafield: 'STARTDATC', width: 100, editable: false },
    { text: 'ACTION', datafield: 'ACTIONC', width: 100, editable: false },
    { text: 'ENTRY', datafield: 'ENTRYC', width: 80, editable: false },
    { text: 'STATUS',columntype: 'dropdownlist',source:stat,datafield: 'STATUSC', width: 110, editable: true,
    	createeditor: function (row, column, editor) {
    		editor.jqxDropDownList({ autoDropDownHeight: true, source: stat });},
    	validation: function (cell, value) {
              if (value == "NO" || value == "YES" || value == "WAIT"  || value == "TO BE DISCUSSED"  || value == "NEW" || value == "")
    	  {
    		pat= $("#jqxgrid").jqxGrid('getcellvalue', rowindex, 'PATIDENT'); /*VALUE OF THE FIELD NAME OF THE LINE MODIFIED */;
    		adr= $("#jqxgrid").jqxGrid('getcellvalue', rowindex, 'ADRNBA'); /*VALUE OF THE FIELD NAME OF THE LINE MODIFIED */;
    		split= $("#jqxgrid").jqxGrid('getcellvalue', rowindex, 'ROWSPLIT'); /*VALUE OF THE FIELD NAME OF THE LINE MODIFIED */;
    		$("#jqxgrid").jqxGrid({ disabled: true});
    		
    	   $.ajax({
    		type : 'POST', // envoi des données en GET ou POST
    		beforeSend : function() { // traitements JS à faire AVANT l'envoi
    			$("#ariane").after('<span id="ajax-loader1"><img style="margin-top:11px;margin-left:265px;height:18px;position:absolute" src="'+web_path_p+car_b+'Librairies'+car_b+'Images'+car_b+'ajax-loader2.gif" alt="image du loader" /> </span');
    			},
    		url : 'http:'+server_sp+'/Coding/IMERIN/maj_status',	// url du fichier de traitement	
    		/*async:false,*/
    		data : '&product='+product+'&study='+study+'&expltn='+expltn+'&STATUS='+value+'&PATIDENT='+pat+'&ADRNBA='+adr+'&ROWSPLIT='+split,
    		dataType : 'json',
    		success  : function(data){},
    		complete :function(data){
    					$('#ajax-loader1').remove();
    					log("Log\\maj_status.log","Update status is ok : changed by "+value+" for "+pat+"/"+adr+split+"");
    		}										
    		});
    	  }
             return true;
    
      }
    	},
    • This topic was modified 9 years, 3 months ago by  nico86.
    • This topic was modified 9 years, 3 months ago by  nico86.
    • This topic was modified 9 years, 3 months ago by  nico86.

    Dimitar
    Participant

    Hi nico86,

    I think it would be better if you make your Ajax call in another column callback function – cellendedit. Here is information about it from the jqxGrid API Documentation:

    cellendedit – sets a custom function which is called when a cell leaves the edit mode. The Grid passes 5 parameters to it – row index, column data field, column type, old cell value, new cell value. The function can be used for canceling the changes of a specific Grid cell. To cancel the changes, the function should return false.

    { text: ‘Product’, datafield: ‘productname’,
    cellendedit: function (row, datafield, columntype, oldvalue, newvalue) {
    if (newvalue == “My Value”)
    return false;
    }
    }

    Best Regards,
    Dimitar

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


    nico86
    Participant

    it work fine with cellendedit
    I had not thought to this function because with my old grid my ajax request was passed in validation and everything worked
    Thanks a lot

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

You must be logged in to reply to this topic.