volosoft / jtable

A JQuery plugin to create AJAX based CRUD tables.
http://www.jtable.org
1.1k stars 505 forks source link

How to add dropdown option in jtable grid as inline #2116

Open mahajanrahuld opened 7 years ago

mahajanrahuld commented 7 years ago

HI team,

I need functionality to dynamically add drop down for each row inside jtable grid.

How to add drop-down? I have seen couple example of your grid, In all example shown dropdowns in edit popup.

Thanks

dasguptahirak commented 7 years ago

Use custom display option in your field like this:

display: function(data){

var select = "<select name='selectName' style='min-width:150px' data-id='"+data.record.id+"' >";

selects += "<option value='' disabled selected>Some placeholder</option>";

for (var i = 1; i <= OptionsValuesFromDatabasse; i++) {
selects += "<option value='"+i+"'>"+i+"</option>";
}

selects += "</select>";
return selects;

}

mahajanrahuld commented 7 years ago

How to make our jtable grid in inline edit mode. I want to implement inline edit functionality. Edit filed should be dropdown ?

On submitt button click read all selected row value

mahajanrahuld commented 7 years ago

How to add textbox inside jtable row for inline editing?

cairnswm commented 7 years ago

Currently inline editing is not supported by jTable. To make this work you would need to write some Java Script to do it.

  1. Add a field on the table that allows you to edit (currently you cannot add a customizable edit feature) 2.when triggered it must include the record key. You can then use GetRowByKey to get the row in the table that you are editing.
  2. Convert each cell in the table to the relevant edit box, and add a submit button somewhere
  3. on submit, do updateRecord and replace the inline edits with the original text again.

It is an interesting problem and I think my suggestion above would work. I'd need some time to actually be able to get an example working for it.