How to display my search to my table in VueJs? - node.js

I just want to ask, I want to display the searched value in my table?
Below code displays Memb_ID in div.
div>
<div class="search-wrapper">
<input type="text" v-model="search" placeholder="Search title..">
<label>Search title:</label>
</div>
<div v-for="cust in filteredList" :key="cust.id">{{ cust.Memb_ID }}</div>
<div class="myTable table-responsive">
<table class="table">
<thead class="thead-dark">
<tr>
<th>Member ID</th>
<th>First Name</th>
<th>Middle Name</th>
<th>Last Name</th>
<th>Address</th>
<!-- <th>URL</th> -->
</tr>
</thead>
<tbody>
<tr v-for="result in results" :key="result.id">
<td>{{result.Memb_ID}}</td>
<th>{{result.First_Name}}</th>
<th>{{result.Middle_Name}}</th>
<th>{{result.Last_Name}}</th>
<th>{{result.Address}}</th>
<!-- <th>{{user.url}}</th> -->
</tr>
</tbody>
</table>
</div>
This is the output of my code.
I want something like this
I got the code from this question but couldn't implement on my own. Thanks for help!

So I thought I solved my problem by looping in the table body.
There's a bug in here. Every time I reload the page it doesn't load the vue file lol. I thought it was okay after refreshing the page it didn't display the table.
I don't know the bug
<div>
<input type="text" v-model="search" placeholder="Search title..">
</div>
<div class="myTable table-responsive">
<table class="table">
<thead class="thead-dark">
<tr>
<th>Member ID</th>
<th>First Name</th>
<th>Middle Name</th>
<th>Last Name</th>
<th>Address</th>
</tr>
</thead>
<tbody>
<tr v-for="result in filteredList" :key="result.id">
<td>{{result.Memb_ID}}</td>
<th>{{result.First_Name}}</th>
<th>{{result.Middle_Name}}</th>
<th>{{result.Last_Name}}</th>
<th>{{result.Address}}</th>
</tr>
</tbody>
</table>
</div>
and in script
computed: {
filteredList() {
return this.results.filter(customer => {
customer.Memb_ID.toLowerCase().includes(this.search.toLowerCase());
});
}
},

Related

How to read value from custom HTML Table in Suitelet 2.0 in POST Method

I am Having a custom HTML Page in suitelet. I that HTML page i have a table with different tags. i need to read HTML table data and loop the table in suitelet 2.0 POST Method.
<table class="table" id="custpage_business_class_tb">
<thead class="thead-light">
<tr>
<th >Classification</th>
<th >Applicable</th>
<th >Certificate Number</th>
<th >Certifying Agency</th>
<th >Expiration Date</th>
</tr>
</thead>
<tbody>
<#list ds.bussclasslist as busclass>
<tr>
<td>
<select name="custpage_busclas_list" class="form-control">
<option value="">${busclass.values.name}</option>
</select>
</td>
<td><input type="checkbox" name="custpage_busclas_applicable" class="d-block mx-auto mt-3"></td>
<td><input type="text" name="custpage_busclas_cert_num" class="form-control"></td>
<td><input type="text" name="custpage_busclas_cert_agency" class="form-control"></td>
<td><input type="date" name="custpage_busclas_cert_expdt" class="form-control"></td>
</tr>
</#list>
</tbody>
</table>
SuiteLet 2.0 post Method.
var lineCount = context.request.getLineCount({ group: 'custpage_business_class_tb' });
log.debug('Total lines in Bank Details are:- ' + lineCount);
Any Help will be greatly appreciated.

Find label name which doesn't contain input immediately from a table

I am having a table which contains multiple td/tr.
My problem is label which i want to get doesn't contains input immediately neither that label has any attributes property.
I want to get "Countries of Permanent Residence" and Dates which are in span but doesn't have any properties that span is in div that too doesn't contains any property.
I tried with
formElement[input[name="icims_gh_Permanent_Country_Residence"]]
But don't know how to get associate label.
Html looks like:
<div style="margin:0px">
<table style="width:100%" border="1" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td valign="top">
<div style="margin:0px">
<span style="font-family:arial,helvetica,sans-serif;font-size:12px"> Countries of Permanent Residence (list all) </span>
</div>
</td>
<td valign="top">
<div style="margin:0px">
<span style="font-family:arial,helvetica,sans-serif;font-size:12px"> Dates </span>
</div>
</td>
</tr>
<tr>
<td colspan="2" valign="top">
<div style="margin:0px">
<div>
<input type="hidden" name="icims_gh_Permanent_Country_Residence" value="1">
<a name="0.1_icims_ga_Permanent_Country_Residence"></a>
<div>
<table style="width:100%;border:0px">
<tbody>
<tr>
<td>
<table style="width:100%" border="1" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td valign="top">
<div style="margin:0px">
<span style="font-family:arial,helvetica,sans-serif;font-size:12px">
<input type="text" name="icims_0_permResidenceCountry"> </span>
</div>
</td>
<td valign="top">
<div style="margin:0px">
<span style="font-family:arial,helvetica,sans-serif;font-size:12px">
<input type="text" name="icims_0_permResidenceCountryDates"> </span>
</div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>

ejs template placing things out of order

I am using an ejs template to loop through an array and add rows to a table. Here is the following code in my template:
<div class="col-md-8 col-md-offset-2">
<table class="table table-hover">
<thead>
<tr>
<th>
Title
</th>
<th>
Creator
</th>
</tr>
</thead>
<tbody>
<tr class="createNewBoard">
<th scope="row">
Add New
</th>
<td>
+
</td>
</tr>
<% boards.forEach(function(board) { %>
<a href="/<%= board._id %>">
<tr>
<th scope="row">
<%= board.title %>
</th>
<td>
<%= board.creator %>
</td>
</tr>
</a>
<% }) %>
</tbody>
</table>
</div>
And here is what is produced:
<div class="col-md-8 col-md-offset-2">
<table class="table table-hover">
<thead>
<tr>
<th>
Title
</th>
<th>
Creator
</th>
</tr>
</thead>
<tbody>
<tr class="createNewBoard">
<th scope="row">
Add New
</th>
<td>
+
</td>
</tr>
<tr>
<th scope="row">
Yooo
</th>
<td>
gus.henry#me.com
</td>
</tr>
<tr>
<th scope="row">
Swag
</th>
<td>
gus.henry#me.com
</td>
</tr>
</tbody>
</table>
</div>
Why is it placing the anchor tags at the top, rather than in the table rows? Other than ejs, using bootstrap.
Thanks.
This is to do with the way tables are parsed in compliant browsers (i.e. chrome).
your <a> tag should be inside a <td></td> to be valid HTML, and chrome for one will move it out of the <tbody> when it renders the page.
Because ejs is interpreted by the server, the browser never sees any of the ejs <% %> stuff - so do a 'view source' on your output page and you'll see the <a> tags where you expected them to be.
It looks like you're trying to cause a click on a table row to navigate to your /[board id] page. You can instead do something like the this:
<% boards.forEach(function(board) { %>
<tr onclick="javascript:window.location='/<%= board._id %>';">
<th scope="row">
<%= board.title %>
</th>
<td>
<%= board.creator %>
</td>
</tr>
<% }) %>
Or, if you really want a non-javascript solution, you could position an <a> tag absolutely (so it covers the cell) in each <td> and <th> as follows:
<% boards.forEach(function(board) { %>
<tr>
<th scope="row">
<%= board.title %>
<a class="coveringA" href="/<%= board._id %>"></a>
</th>
<td>
<%= board.creator %>
<a class="coveringA" href="/<%= board._id %>"></a>
</td>
</tr>
<% }) %>
with accompanying css as follows:
table td {
overflow:hidden;
}
.coveringA {
position:absolute;
display:block;
top:0px;
left:0px;
right:0px;
bottom:0px;
background:rgba(0,0,0,0); /* sets an invisible background to ensure its clickable in IE9 */
}

Nested Repeaters Using Table Tags

I am using the following code to try and use nested repeaters in WinJS:
<table class="grid" id="rptCustomerHistory" data-win-control="WinJS.UI.Repeater">
<thead>
<tr>
<th colspan="4" class="groupHeader" data-win-bind="textContent: GroupDate.DateTime BindingConverter.toYearMonthDate"></th>
</tr>
</thead>
<tbody data-win-control="WinJS.UI.Repeater" data-win-bind="winControl.data: ch">
<tr>
<td data-win-bind="textContent: ContactDate.DateTime BindingConverter.toshortdate"></td>
<td data-win-bind="textContext: SalesPerson"></td>
<td data-win-bind="textContext: ContactMethod"></td>
<td><span class="symbol"></span></td>
</tr>
</tbody>
</table>
However, it is not rendering any results for the 2nd repeater.
When I use the same data source and similar markup using DIVs, it works:
<div id="rptCustomerHistory" data-win-control="WinJS.UI.Repeater">
<div>
<div data-win-bind="textContent: GroupDate.DateTime BindingConverter.toYearMonthDate"></div>
<div data-win-control="WinJS.UI.Repeater" data-win-bind="winControl.data: ch">
<span data-win-bind="textContent: ContactMethod"></span>
</div>
</div>
</div>
I don't really want to use Divs as this is tabular data. Any idea why using table tags behaves differently?
Did you assign give data to your outer repeater?
The following works in a blank project for me:
<script>
window.list = new WinJS.Binding.List([
new WinJS.Binding.List([1, 2, 3]),
new WinJS.Binding.List([4, 5, 6]),
]);
</script>
<div data-win-control="WinJS.UI.Repeater" data-win-options="{ data: list }">
<span data-win-control="WinJS.UI.Repeater" data-win-bind="winControl.data : this"></span>
</div>
Try replacing
data-win-bind="winControl.data: ch"
with:
data-win-options="{data: ch}"

Trying to use laravel pagination breaks my controller/view

I'm trying to get Pagination working in Laravel. I've not used pagination before so am trying to use some examples from the docs and google results. I'm wondering if I need to turn 'pagination' on somewhere in config.
Here's my simple working controller:
public function get_index() {
$locations = Location::all();
return View::make('location.index')->with('locations', $locations)->render();
}
When I try and add pagination like this it breaks:
public function get_index() {
$locations = Location::paginate(5);
return View::make('location.index')->with('locations', $locations)->render();
}
..and I get the error:
Unhandled Exception
Message:
Error rendering view: [location.index]
Trying to get property of non-object
Here's my location.index view:
#layout('layouts.blank')
#section('content')
<div class="row">
<div class="twelve columns">
<div role="main" id="content">
<h3>Locations - All</h3>
#if($locations)
<table class="twelve">
<thead>
<tr>
<th style="text-align: left;">Address</th>
<th>Area</th>
<th>Region</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
#foreach($locations as $location)
<tbody>
<tr>
<td style="text-align: left;">{{ $location->company,', ',$location->add_name,', ',$location->add_city }}</td>
<td> – </td>
<td> – </td>
<td>{{ HTML::link('location/update/'.$location->id, '',array('class'=>"foundicon-edit updateicon")) }}</td>
<td>{{ HTML::link('location/delete/'.$location->id, '',array('class'=>"foundicon-remove warnicon")) }}</td>
</tr>
</tbody>
#endforeach
</table>
#else
Looks like we haven't added any locations, yet!
#endif
<p>{{ HTML::link('location/create', 'Create a location', array('class'=>"small radius button")) }}</p>
</div>
</div>
</div>
#endsection
I hadn't read deeply enough into the subject. It's now working and here's what I had to change in the view:
//from:
#foreach($locations as $location)
//to:
#foreach($locations->results as $location)
That returned just 5 results. Then to add links to the footer of my table I added this HTML/Blade:
<tfoot>
<tr>
<td colspan="5"> {{ $locations->links() }} </td>
</tr>
</tfoot>
Hope someone else benefits as I didn't find this terribly clear in the docs.

Resources