easyui 的 combogrid

easyui of combogri drop-down box used in the project a lot, sometimes a lot of problems, of course, Ye Hao solve.

1. When the id value passed to the background, and the query entered by the user out of the displayed values ​​same, but combogrid is empty?

  Scenario: Enter 'John Doe', and displays the same value but not selected, combogrid empty

 

Such surface is entered, but the value is not 01, but Joe Smith.

// this should be another way for combogrid value
<input type="text" id="data"></input>
// js Code
var rows = $("#data").combogrid("grid").datagrid("getSelected") || {};
was id = rows.id;
if(!id){
   $ .messager.alert ( "prompt", "Please select an existing person!", "info" );
   return;
}

 This prevents the user enters the correct background processing error but embarrassment.

2. Clear the code component values, but there is no trigger event, the value is always transmitted once (without refreshing the page)

 $("#Btn").linkbutton({
            text: 'return' ,
            iconCls:'icon-back',
            onClick:function () { $ ( "# the Data") combogrid ( "the Clear." ); // trigger button, the drop-down box to clear component values, did not trigger the following attributes. Enter a different value or the last value in the future TRANSFERRED
          
        })

solve:

// trigger an event when you define the drop-down box 
var $ data = $ ( "# data"). Combogrid ({
    idField: '', 
the textField: 'name',
URL: '/html/data.json',
Method: 'GET',
Columns: [[
{Field: 'ID', title: 'ID', width: 80},
{field: 'name', title : ' name', width: 80},
]],
onShowPanel: function () {// display panel when the pull-down trigger.
if ($ data) {// determines whether initialized
var data.combogrid K = $ ( "getText");
$ data.combogrid ( "Grid") DataGrid ( 'Load', {.
Q: K
})
}
}
} );

Guess you like

Origin www.cnblogs.com/Choleen/p/11809324.html