jQWidgets Forums

jQuery UI Widgets Forums Grid jqxDropDownList in jqxGrid,the checkedItem will be null after click few times

This topic contains 2 replies, has 2 voices, and was last updated by  bruthe 11 years, 5 months ago.

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

  • bruthe
    Participant
    $(document).ready(function () {
    	
    	var theme = 'office'
    	
    	var source = {
    		datatype: "json",
            datafields:[
     			{ name: 'username', type: 'string' },
     			{ name: 'email', type: 'string' },
     			{ name: 'teamName', type: 'string' },
     			{ name: 'supervisor', type: 'bool' },
     			{ name: 'id', type: 'int' },
            ],
            url: _BASE_URL + 'team/memberListAsJSON',
            updaterow: function (rowid, rowdata) {                    
                var data = $.param(rowdata);
                //alert(data)
                $.ajax({
                    dataType: 'json',
                    url: _BASE_URL + 'team/updateMember',
                    data: data,
                    success: function (data, status, xhr) {
                        // update command is executed.
                    	if(data.success){
                    		//alert("update success!");
                    		var addOpt = $("select#orgMaster option[value='"+data.name+"']")
                    		if(data.isSupervisor){
                    			if(!addOpt){
                    				$("select#orgMaster").append("<option value='"+data.name+"'>"+data.name+"</option>")
                    			}
                    		}else{
                    			addOpt.remove()
                    		}
                    	}else{
                    		//alert(data.error);
                    	}
                    }
                });
            }
    	};
    	
    	var dataAdapter = new $.jqx.dataAdapter(source,{
    		downloadComplete: function (data, status, xhr) { },
            loadComplete: function (data) { $("#jqxgrid").jqxGrid('hidecolumn', 'id'); },
            loadError: function (xhr, status, error) { alert(JSON.stringify(xhr)); }
    	});
    	
    	var getEditorDataAdapter = function (datafield) {
            var source =
             {
    	         datatype: "json",
    	         datafields: [{name: 'teamName'}],
    	         url: _BASE_URL + 'team/orgsName',
    	         async: false
             };
            var dataAdapter = new $.jqx.dataAdapter(source, { uniqueDataFields: [datafield] });
            return dataAdapter;
        }
    	
    	// initialize jqxGrid
        $("#jqxgrid").jqxGrid(
        {
            width: 858,
            height:305,
            source: dataAdapter,
            pageable: true,
            editable: true,
            sortable: true,
            //theme: theme,
            theme: theme,
            filterable: true,
            //selectionmode: 'multiplecellsadvanced',
            selectionmode: 'singlecell',
            columns: [
              { text: 'User Name', columntype: 'textbox', datafield: 'username', width: 236 },
              { text: 'Email',     columntype: 'textbox', datafield: 'email', width: 236 },
              { text: 'Organization', columntype: 'template', datafield: 'teamName', width: 150 ,
            	  createeditor: function (row, cellvalue, editor, celltext, width, height) {
                      // construct the editor. 
                      editor.jqxDropDownList({
                          checkboxes: true, source: getEditorDataAdapter('teamName'), displayMember: 'teamName', valueMember: 'teamName', 
                          width: width, height: height, theme: theme,
                          autoDropDownHeight: true,
                          selectionRenderer: function () {
                              return "Please Choose Team:";
                          }
                      });
                  },
                  initeditor: function (row, cellvalue, editor, celltext, pressedkey) {
                      // set the editor's current value. The callback is called each time the editor is displayed.
                	  var items = editor.jqxDropDownList('getItems');
                      editor.jqxDropDownList('uncheckAll');
                      //var values = cellvalue.split(/,\s*/);
                      var values = cellvalue;
                      for (var j = 0; j < values.length; j++) {
                          for (var i = 0; i < items.length; i++) {
                              if (items[i].label === values[j]) {
                                  editor.jqxDropDownList('checkIndex', i);
                              }
                          }
                      }
                  },
                  geteditorvalue: function (row, cellvalue, editor) {
                      // return the editor's value.
                      return editor.val();
                  }
              },
              { text: 'Supervisor',   columntype: 'checkbox', datafield: 'supervisor'}
            ]
        });
        
        // events
        $("#jqxgrid").on('cellbeginedit', function (event) {
            var args = event.args;
            $("#cellbegineditevent").text("Event Type: cellbeginedit, Column: " + args.datafield + ", Row: " + (1 + args.rowindex) + ", Value: " + args.value);
        });
    
        $("#jqxgrid").on('cellendedit', function (event) {
            var args = event.args;
            $("#cellendeditevent").text("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (1 + args.rowindex) + ", Value: " + args.value);
        });
    });

    the reveal of data have any problem,but have these problem:
    1.the jqxDropDownList cell will send ajax request when you double click the element,but the real is
    you want to send update request when the checked item is changed
    2.Frequent Click the jqxDropDownList cell, the checked item of jqxDropDownList will be null, I can’t
    find where the problem

    –>
    jqxDropDownList JSON data:
    [{“id”:1,”teamName”:”BullChina”,”parent”:null,”master”:null,”viceMaster”:null,”productOwner”:null}, …]

    –>
    [{“username”:”lei.liu-bj”,”email”:”lei.liu-bj@qq.com”,”teamName”:[“FLEX”],”supervisor”:false},….]

    anyone can help me ,thank very much !!!


    Dimitar
    Participant

    Hello bruthe,

    1. The source callback function updaterow is invoked when the method with the same name has been called;
    2. Please clarify your issue and post exactly how it can be reproduced. Do you experience it with the demo Custom Column Editor?

    Best Regards,
    Dimitar

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


    bruthe
    Participant

    Hi Dimitar.
    Thank you for you taking time out of your busy schedule to look my problem!

    I have read the demo ,the problem is jqxDropDownList in grid
    can’t update data in real time with background ,and sometime get the checkedItem from background in jqxDropDownList may
    not correct. i have already change a another way to edit table.

    Thank you!

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

You must be logged in to reply to this topic.