Show Posts
|
Pages: [1]
|
1
|
General Category / EasyUI for jQuery / Re: Datagrid cel editing with combobox
|
on: January 10, 2016, 08:02:04 PM
|
IT'S WORK, THANK YOU! for who maybe need it, here is my working code: var color_obj=[]; . . . // datagrid options.. ... columns:[[ {field:'fruit',title:'Fruit'}, {field:'color_option',title:'Color', formatter:function(v){ if(v=='') return 'Choose the right color...'; else return v; }, editor:{ type:'combobox', options:{ valueField:'val', textField:'txt', //required:true } } }, onBeginEdit:function(index,row){ var color_obj=$.map(row.color_option.split(','),function(c){ return { val:c, txt:c } }); var color_cell=$(this).datagrid('getEditor',{ index:index, field:'color_option' }); var cc=$(color_cell.target); cc.combobox('loadData',color_obj); }, onClickCell:function(index,field,value){ // copied from Demo page }, onEndEdit:function(index,row){ // copied from Demo page } ]]
Thank you.
|
|
|
2
|
General Category / EasyUI for jQuery / Datagrid cel editing with combobox
|
on: January 09, 2016, 01:38:02 AM
|
I have a datagrid table with rows data json look like this: { "rows":[ {"fruit":"Apple","color_option":"red,purple,blue"}, {"fruit":"Banana","color_option":"purple,yellow,red"} ], "total":"2" } And the columns option for my table look like this: var color_obj=[]; . . . // datagrid options.. ... onClickCell:onClickCell, // i copied the row editing code from the Demo page. onEndEdit:onEndEdit, columns:[[ {field:'fruit',title:'Fruit'}, {field:'color_option',title:'Color', formatter:function(v){ color_obj=[]; colors=v.split(",") // i try to convert the color_option string as object // to make it readable as combobox data $.each(colors,function(i,j){ color_obj.push({val:j,txt:j}) }) return 'Choose the right color...'; }, editor:{ type:'combobox', options:{ data:color_obj, valueField:'val', textField:'txt', required:true } } } ]] When i run it, combobox are works but the option list is blank. I'm sure my combobox codes still not complete, i wish to make a combobox with options from the color_option string that are different on each rows. Please help. Thank you.
|
|
|
4
|
General Category / EasyUI for jQuery / Re: How to stop disableFilter for requesting server's data
|
on: July 10, 2015, 10:07:35 PM
|
i tried to jsfiddle, but i dont know.... this is my code, --i made it simple--- <body> <h3>Students</h3> <div id='students'></div> <h4>Subject</h4> <div id='subject'></div>
<script> $(function(){ var classroom={}; classroom.rows = [ {id:"C1",name:"Daisy"}, {id:"C2",name:"Tulip"}, {id:"C3",name:"Rose"}, {id:"C4",name:"Aster"}, {id:"C5",name:"Lily"}, ]; classroom.total = classroom.rows.length; var students=$('#students').datagrid({ singleSelect:true, data:classroom, //actually i use url: at my localhost web pageSize:10, rownumbers:true, pagination:true, remoteSort:true, remoteFilter:true, filterDelay:1000, idField:'id', columns:[[ {field:'cek',checkbox:true}, {field:'id',title:'#'}, {field:'name',title:'Classroom'} ]] }) var subject=$('#subject').datagrid({ singleSelect:true, pageSize:10, pagination:true, rownumbers:true, idField:'cr_id', remoteFilter:true, remoteSort:true, columns:[[ {field:'name',title:'Student Name'}, {field:'point',title:'Points'} ]] }) subject.datagrid({queryParams:{cr_id:'C1',type:'students'}}) subject.datagrid('enableFilter') function seeDetail(id){ /* for avoiding 'uncaught range error maximum call stack size exceeded' i use disableFilter first, query the data and then enable it again. but the disableFilter keep trigger query to server with old queryparams */ subject.datagrid('disableFilter'); subject.datagrid({queryParams:{cr_id:id,tipe:'students'}}); subject.datagrid('enableFilter'); } students.datagrid({ onSelect:function(i,r){ id=r.id; seeDetail(id); } }) }) </script> </body>
thank you Edit: cleaning code
|
|
|
5
|
General Category / EasyUI for jQuery / [SOLVED] How to stop disableFilter for requesting server's data
|
on: July 10, 2015, 03:54:35 PM
|
Hello,
I have a datagrid using queryParams with dynamic variable, like: queryParams:{student:name,id:number}, and i also enable filter on it. I got several problem that i manage to 'trick' but then i've got deadend, this is what i've done and i cant:
1. at first i only 'enableFilter' once, then request data with queryParams with changed variable 'name' and 'number', but always ended with 'uncaught range error maximum call stack size exceeded' on chrome's console. then i just disableFilter before i queryParams and then enable it again after that. Works find and i like it. But this not an elegance way, maybe there is another way for this?
2. then this problem came, every time disableFilter triggered, datagrid will request data from servers, and that makes 2 query with queryParams. How can i prevent this?
Thank you
|
|
|
|