setvalue.html 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Set Value for ComboGrid - jQuery EasyUI Demo</title>
  6. <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
  7. <link rel="stylesheet" type="text/css" href="../../themes/icon.css">
  8. <link rel="stylesheet" type="text/css" href="../demo.css">
  9. <script type="text/javascript" src="../../jquery.min.js"></script>
  10. <script type="text/javascript" src="../../jquery.easyui.min.js"></script>
  11. </head>
  12. <body>
  13. <h2>Set Value for ComboGrid</h2>
  14. <p>Click the buttons below to perform actions.</p>
  15. <div style="margin:20px 0">
  16. <a href="javascript:void(0)" class="easyui-linkbutton" onclick="getValue()">GetValue</a>
  17. <a href="javascript:void(0)" class="easyui-linkbutton" onclick="setValue1()">SetValue1</a>
  18. <a href="javascript:void(0)" class="easyui-linkbutton" onclick="setValue2()">SetValue2</a>
  19. </div>
  20. <div class="easyui-panel" style="width:100%;max-width:400px;padding:30px 60px;">
  21. <div style="margin-bottom:20px">
  22. <select id="cc" class="easyui-combogrid" style="width:100%" data-options="
  23. panelWidth: 500,
  24. idField: 'itemid',
  25. textField: 'productname',
  26. url: 'datagrid_data1.json',
  27. method: 'get',
  28. columns: [[
  29. {field:'itemid',title:'Item ID',width:80},
  30. {field:'productname',title:'Product',width:120},
  31. {field:'listprice',title:'List Price',width:80,align:'right'},
  32. {field:'unitcost',title:'Unit Cost',width:80,align:'right'},
  33. {field:'attr1',title:'Attribute',width:200},
  34. {field:'status',title:'Status',width:60,align:'center'}
  35. ]],
  36. fitColumns: true,
  37. label: 'Select Item:',
  38. labelPosition: 'top'
  39. ">
  40. </select>
  41. </div>
  42. </div>
  43. <script type="text/javascript">
  44. function getValue(){
  45. var val = $('#cc').combogrid('getValue');
  46. alert(val);
  47. }
  48. function setValue1(){
  49. $('#cc').combogrid('setValue', 'EST-13');
  50. }
  51. function setValue2(){
  52. $('#cc').combogrid('setValue', {
  53. itemid: 'customid',
  54. productname: 'CustomName'
  55. });
  56. }
  57. </script>
  58. </body>
  59. </html>