|
FAQ
Frequently Asked Questions.
Frequently Asked QuestionsTypical Grid and Debug toolsIn these examples, we use a typical Grid: var myFlex = {
autoload : false,
dataType : 'json',
url : 'grid.php',
usepager : true
};
$('#grid01').flexigrid($.extend({}, myFlex, {
colModel : [
{name: 'name', display: 'NAME', sortable: true},
{name: 'status', display: 'STATUS', sortable: true},
{name: 'sign', display: 'SIGN', sortable: true}
]
})); For debug we use console.log() more likely than alert(), which is not always work as expected. Examples
Dynamic columns and Post parameter to serverColmodel define in variable. Parameters send to server by .flexOptions() on onSubmit(). var colModel01 = [
{name: 'name', display: 'NAME', sortable: true},
{name: 'status', display: 'STATUS', sortable: true},
{name: 'sign', display: 'SIGN', sortable: true}
];
$('#grid01').flexigrid($.extend({}, myFlex, {
colModel : colModel01,
onSubmit : function(){
$('#grid01').flexOptions({params: [
{name:'colls', value: $.param({colls: $.map(colModel01, function(elem,id){return elem.name}) }) }
]});
return true;
}
})); In this code we post to server on load next data (with column names): page=1&rp=15&sortname=undefined&sortorder=undefined&query=&qtype=& colls=colls%255B%255D%3Dname%26colls%255B%255D%3Dstatus%26colls%255B %255D%3Dsign Get selected rowThe difficulty lies in linking: column_name - data. That is why the order of columns can be changed, and we can not use index in the array of row cells. In flexigrid-1.1 we have the attribute 'abbr' for sortable table cells (issue 46). $('#grid01').click(function(event){
$('.trSelected', this).each( function(){
console.log(
' rowId: ' + $(this).attr('id').substr(3) +
' name: ' + $('td[abbr="name"] >div', this).html() +
' sign: ' + $('td[abbr="sign"] >div', this).html() +
' status: ' + $('td[abbr="status"] >div', this).html()
);
});
});Mouseclick and other eventsAs of jQuery 1.7, the .on() method provides all functionality required for attaching event handlers. $('.flexigrid').on('mouseenter', 'tr[id*="row"]', function(){
console.log('mouseenter rowId: ' + $(this).attr('id').substr(3));
});With older jQuery: If we bind the event to the cells, we have to use the .live() or .delegate(). Because it when receiving data grid content is recreated. $('.flexigrid tr[id*="row"]').live('mouseenter', function(){
console.log('mouseenter rowId: ' + $(this).attr('id').substr(3));
});Multiple filtersJust add a custom filter form <form id="fmFilter">
<input id="fmFilterSel1" name="fmFilterSel1" type="checkbox" />
<input id="fmFilterSel2" name="fmFilterSel2" type="checkbox" />
<input id="fmFilterSel3" name="fmFilterSel3" type="text" />
</form>
<table id="grid01"><tr><td></td></tr></table>
<script>
$('#grid01').flexigrid($.extend({}, myFlex, {
onSubmit : function(){
$('#grid01').flexOptions({params: [{name:'callId', value:'grid01'}].concat($('#fmFilter').serializeArray())});
return true;
}
});
</script> And you send to server the filter condition of any complexity. Format cellsYou can colorize the cells, and even change the output according to the received data. function gridFormat() {
var lblStatus = {
'101' : {
css : '',
txt : 'STATUS_OK'
},
'102' : {
css : 'cellDisable',
txt : 'STATUS_LOCK'
},
'103' : {
css : 'cellWarning',
txt : 'STATUS_BAD'
}
};
$('#grid01 tr').each( function(){
var cell = $('td[abbr="status"] >div', this);
$(this).addClass( lblStatus[cell.text()].css );
cell.text( lblStatus[cell.text()].txt );
});
return true;
}
$('#grid01').flexigrid($.extend({}, myFlex, {
buttons : [
{name: 'CLEAR', onpress: function(com,grid){ $('#grid01').flexAddData({rows:[],page:0,total:0}); }},
{name: 'FILL', onpress: function(com,grid){ $('#grid01').flexAddData({rows:[
{id:'id0',cell:['name00',101,'A']},
{id:'id1',cell:['name01',102,'B']},
{id:'id2',cell:['name02',103,'C']}
],page:1,total:3}); }}
],
onSuccess : gridFormat
}); In this example, the Grid has a buttons for fill/clear the test data. In column "status" we provide text labels for numeric values. Keep in mind that 'abbr' implemented in sortable columns only (#Get_selected_row). |
Select row by ID:
How to add hyperliked values in flexigrid cells? Please suggest.
Hi,
I have within a popup flexigrid. I am not able to dynamically add a column to the flexigrid based on some condition..
any suggestion on how to go ahead with this?
Sorry, I'm new in this and I could use the grid without any problem, but I have one question, How can I put the images in the buttons? because the the words (add, edit and delete) appear alone.
shan2005india, aji4all, knio16, wellcome to forum http://groups.google.com/group/flexigrid/browse_thread/thread/75ab9783ce684e56
how can I contribute to this project ? Is there some agreement for me to sigh?
Guys dont continue with this component I have may issues for monts its better Kendo UI Framework its the best solution http://demos.kendoui.com/web/grid/index.html
I need a hint, i'm using this "library" to query a DB and it's working very nice, great code guys.
But i need a little hint, i want to be able to select a row with a mouse click a "expand" the results on the same page on a "div" or something like it.
I have the code working showing the results with the "console.log" debugging, but i can't use it to show on a page :( Can someone help? Thanks
this code will help you $('#flex1').click(function(event){
A
I'm wondering how to clear the search field value when it is hidden. See http://stackoverflow.com/questions/9742293/jquery-flexigrid-search-value-not-cleared
Thanks for any help. Mark
For some reason, there are no icons for add, edit, or delete on my flexigrid. I have:
buttons : [ {name: 'Add', bclass: 'add_small', onpress : takeAction}, {name: 'Edit', bclass: 'edit', onpress : takeAction}, {name: 'Delete', bclass: 'delete', onpress : takeAction}, {separator: true} ],and image files (tried different types) for the each of the bclass above. The online examples have icons, but there aren't any images included with the flexigrid download.
Can you help?
u can find a concise thread to extend the flexigrid http://eaziweb.blogspot.com/2011/09/extend-flexigrid.html
Hi,
How can I make the table unscrollable? I want it to have some specific width and height, resizable is set to false, but still it scrolls. I want to use the pager only to get to the next available records.
Thanks!
Susana
Hi,
One more question, is it possible to have a column in the column model which is not visible? I wanted to have an id of some record available, but I don't want to show it in the page.
Thanks again,
Susana
Yes it is possible;
align: 'left', hide: true},Hello guys
I use this code to do action on single click
I want to do the same but on double click (not single click) ?Hello All
i am using dynamic html table and filling data to it dynamically using Linq List it is working good but my pager is not working plz help me and i am trying to fix i text box on top of each coulmn just below the header to use as filter i set the text box well, but now i dont know how to connect it to data to use as filter please help me umeshsinghgarg@gmail.com
Hi there,
I need to figure out how to format the date in a column that is NOT flexigrids id. I followed the code below to see if I could reach a cell“s value. I do get the rowID as the correct value, but all other values are returned "null". All columns are sortable.
Any suggestions?
((( $('#flex1').click(function(event){
});