Reputation: 25
I have a drop-down
in j-table
and I want to extract the selected value
from it. Is there any way to get the selected option
values from j-table.
sections_template_id: {
title: 'Template',
inputTitle: "Template*",
options: web_sections,
create: true,
edit: true,
list: true
}
, sec_hidden: {
type: 'hidden'
, inputTitle: "Template*"
, create: true
, edit: false
, list: false
, defaultValue: web_sections
}
i want to set the value of sections_template_id
in sec_hidden
this is my route on which i am calling a function
Route::post('cms-web-section-templates',['as' => 'cms-web-section-templates', 'uses' => 'CmsController@Main_sections']);
and here is my function
public function Main_sections(Request $request)
{
$types = SectionType::getTypes();
$web_section = WebTemplate::all();
//dd($web_section);
$rows[] = array("DisplayText"=>"", "Value"=>"");
foreach ($web_section as $key => $web_sections) {
$rows[] = array(
'DisplayText' => $web_sections->name,
'Value' => $web_sections->id,
);
}
$this->response['Options'] = $rows;
$this->response['Result'] = "OK";
return json_encode($this->response);
}
Upvotes: 0
Views: 883
Reputation: 185
Try the jtable selectedRows
method to get a jquery object of the selected rows.
The documentation https://jtable.org/ApiReference/Methods#met-selectedRows has short worked example how to get the record and fields for each selected row.
Upvotes: 0
Reputation: 281
I used jquery/javascript to grab data from jtable
. I cant find in the jtable documentation how to grab the selected value. If you inspect element, once you select the row, a class is added in that row which is "jtable-row-selected".
<script>
var all_rows = [];
$('tr.jtable-row-selected').each(function(){
var len = $(this).children().length;
var row = [];
for(let i = 0;i < len; i+=1){
row.push($(this).children()[i].innerText)
}
all_rows.push(row);
})
//console.log(all_rows);
</script>
Upvotes: 0