The column is overflowed in table - javascript

Here is my problem. My columns are overflowed and I can't see it.
I know that some columns have a lot of data.
How can I edit HTML or CSS for that? This web I'm writing by Laravel framework.
Here is my source code, please view it. I'm using bootstrap for this.
<div class="box" ng-controller="TinTucNewController">
<div class="box-header">
{{csrf_field()}}
<h3 class="box-title">Danh Sách Tin Tức</h3> <br>
<button class="btn btn-new btn-xs btn-create">
<span class="glyphicon glyphicon-plus"></span>" Bấm vào đây để thêm dữ liệu"</button>
</div>
<div class="box-body">
<table id="example1" class="table table-bordered table-striped">
<thead><tr>
<th>Mã Tin Tức</th>
<th>Thể Loại</th>
<th>Tiêu Đề</th>
<th>Tóm Tắt</th>
<th>Nội Dung</th>
<th>Hình Ảnh</th>
<th>Nổi Bật</th>
<th>Lượt Xem</th>
<th>Tạo mới</th>
<th>Cập nhật</th>
<th>Trạng thái</th>
<th>Công Cụ</th>
</tr>
</thead>
#foreach($ds_tt as $tt)
<tbody><tr>
<td>{{$tt->tt_ma}}</td>
<td>{{$tt->tt_theLoai}}</td>
<td>{{$tt->tt_tieuDe}}</td>
<td>{{$tt->tt_tomTat}}</td>
<td>{{$tt->tt_noiDung}}</td>
<td>
<img width="80" height="50" src="{{asset('upload/tintucnew/'.$tt->tt_hinh)}}"/>
</td>
<td>
#if($tt->tt_noiBat == 0){{'Tin Thường'}}
#else
{{'Tin Hot'}}
#endif
</td>
<td>{{$tt->tt_luotXem}}</td>
<td>{{$tt->tt_taoMoi}}</td>
<td>{{$tt->tt_capNhat}}</td>
<td><?php echo ($tt->tt_trangThai==2)?'Khóa':'Khả dụng' ?></td>
<td>
<button class="btn btn-warning btn-xs btn-edit">
<span class="glyphicon glyphicon-pencil"></span></button>
<button class="btn btn-danger btn-xs btn-delete"
ng-click="confirmDelete({{$tt->tt_ma}})">{{ method_field("DELETE")}}
{{csrf_field()}}
<span class="glyphicon glyphicon-trash"></span></button>
</td>
</tr>
</tbody>
#endforeach
</table>
</div>
</div>

Related

how to change the bind grid view in separately

I created one grid view to get the database table details,
here, when I click the Next Sync button it will pop up this box and I can choose the date and time,
but the problem is when I clicked any Next Sync button only change the first DateTime only,
this is the code of the table grid view
<table class="table table-striped border-bottom">
<thead>
<tr>
<th>Select to Sync.</th>
<th class="sorting">Source</th>
<th>Last Sync. Date</th>
<th>Download</th>
<th>Status</th>
<th>Next Sync Schedule</th>
<th>Schedule</th>
</tr>
</thead>
<tbody data-bind="foreach: PayrollIntegrationVM.GridDataList">
<tr>
<td><input type="checkbox" data-bind="checked:SHTYP_IS_MANUAL_SYNC"
class="i-checks" name="foo"></td>
<td data-bind="text:SHTYP_NAME"></td>
<td data-bind="text: moment(SHTYP_LAST_DATE).format('L LTS')"></td>
<td>
<div data-bind="ifnot: SHTYP_SYNC_STATUS">
<a href="#" data-bind="click: PayrollIntegrationVM.ErrorLog">
<span class="mr-2">
<img src="~/Content/img/icon-excel.png"
alt="Download">
</span> Download Error Log
</a>
</div>
</td>
<td data-bind="text: SHTYP_SYNC_STATUS? 'Success' : 'Failed'"><a href="#">
<i class="fa fa-close text-danger"></i></a></td>
<td data-bind="text: moment(SHTYP_NEXT_DATE).format('L LTS')" id="SHTYP_NEXT_DATE_GET"
name="Sync_Next_Date"></td>
<td><a href="#" id="Next-Sync-Value" data-toggle="modal" data-target="#sync"
name="Next_Sync_button">Next Sync.</a></td>
</tr>
</tbody>
this is the date time picker code
<div class="modal" id="sync" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-body">
<div class="col ml-5 d-flex flex-column justify-content-end">
<input type="date" class="form-control" id="NextSyncDate">
<input type="time" class="form-control mt-2" id="NextSyncTime">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" data-dismiss="modal">
Cancel
</button>
<button type="button" class="btn btn-primary" data-dismiss="modal" onclick="DoneButtonFunction()">Done</button>
</div>
</div>
</div>
</div>
this is the script part
<script language="JavaScript">
function DoneButtonFunction() {
var nextSyncDate = $('#NextSyncDate').val();
var nextSyncTime = $('#NextSyncTime').val();
var DateTime = nextSyncDate +" "+ nextSyncTime;
document.getElementById('SHTYP_NEXT_DATE_GET').innerHTML = DateTime;
}
}
</script>
it looks like in your js function, you find the element with the ID 'SHTYP_NEXT_DATE_GET', and js looks for the first one, try to save the row in the table, or find another way to Identify which 'SHTYP_NEXT_DATE_GET' element you want to edit

How do I pass a C# object as the parameter to a Javascript function

So I have this table which generates it's data based on a collection inside the #Model
#foreach (var number in Model.Numbers)
{
<tr class="tb-tnx-item">
<td class="tb-tnx-id">
<div class="">
<span>#number.Msisdn</span>
</div>
</td>
<td class="tb-tnx-id">
<span>#number.Country</span>
</td>
<td class="tb-tnx-info">
<div class="">
<span class="title">Mobile</span>
</div>
</td>
<td class="tb-tnx-amount">
<div class="tb-tnx-total">
<span class="amount"><em class="icon ni ni-coins align-middle"></em>#number.Cost</span>
</div>
<div class="tb-tnx-status">
<span title="#number.Features" class="">#number.Features[0] / #number.Features[1]</span>
</div>
</td>
<td class="text-center">
<div class="tb-tnx-status">
<a class="btn btn-primary" onclick="doFunction(); ">Default S2</a>
</div>
</td>
</tr>
}
And as you can see I have this part right here which calls upon a JavaScript function when I click on it
<a class="btn btn-primary" onclick="doFunction(); ">Default S2</a>
And here is the JavaScript
<script>
function doFunction() {
alert("Test");
}
</script>
My question is.. How do I pass number as a parameter so that I can do something like this
alert(number.Msisdn);
You should serialize number C# object into a JSON string using Newtonsoft nuget Package
#using Newtonsoft.Json
then pass it to the view as following:
<a class="btn btn-primary" onclick="doFunction(#(JsonConvert.SerializeObject(number)));">Default S2</a>
so final view it will be something like the following:
#using Newtonsoft.Json
#foreach (var number in Model.Numbers)
{
<tr class="tb-tnx-item">
<td class="tb-tnx-id">
<div class="">
<span>#number.Msisdn</span>
</div>
</td>
<td class="tb-tnx-id">
<span>#number.Country</span>
</td>
<td class="tb-tnx-info">
<div class="">
<span class="title">Mobile</span>
</div>
</td>
<td class="tb-tnx-amount">
<div class="tb-tnx-total">
<span class="amount"><em class="icon ni ni-coins align-middle"></em>#number.Cost</span>
</div>
<div class="tb-tnx-status">
<span title="#number.Features" class="">#number.Features[0] / #number.Features[1]</span>
</div>
</td>
<td class="text-center">
<div class="tb-tnx-status">
<a class="btn btn-primary" onclick="doFunction(#(JsonConvert.SerializeObject(number))); ">Default S2</a>
</div>
</td>
</tr>
}

Datatables does not activate

I am using JavaScript to load a file into a div. Which contains a table that I want to activate as DataTable
panel.js:
document.getElementById('navBtnApps').addEventListener('click', loadApps);
function loadApps(){
$('#mainCTN').load("/src/view/apps.php");
$('#tblApps').DataTable();
};
apps.php:
<div class="container pt-4">
<div class="col-12 border-bottom mb-5 pl-0">
<h3 class="display-4">
Your Apps
<button type="button" class="btn btn-success ml-2" data-toggle="modal" data-target="#new">
<i class="fas fa-plus mr-1"></i>
New
</button>
</h3>
</div>
<table id="tblApps" class="table table-striped">
<thead>
<tr>
<th>Application</th>
<th style="width:250px;">Action</th>
</tr>
</thead>
<tbody>
<?php foreach(scandir(dirname(__FILE__,3) . '/apps/') as $app){ ?>
<?php if(("$app" != "..") and ("$app" != ".") and ("$app" != ".htaccess")){ ?>
<tr>
<td><?=$app?></td>
<td>
<form method="post">
<a href="?p=apps&name=<?=$app?>" class="btn btn-sm btn-primary">
<i class="fas fa-eye mr-1"></i>
Details
</a>
<button type="submit" name="DeleteApp" value="<?=$app?>" class="btn btn-sm btn-danger">
<i class="fas fa-trash-alt mr-1"></i>
Delete
</button>
</form>
</td>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
</div>
When I press the navBtnApps button in my index very quickly, I can see that datatables is being activated. But as soon as the page stops loading, datatables gets deactivated. Any ideas why?
With your code:
$('#mainCTN').load("/src/view/apps.php");
$('#tblApps').DataTable();
$().load is asynchronous, so your #tblApps doesn't exist when you immediately (before it's finished loading) call .DataTable() on it.
Add the call into the $.load callback:
$('#mainCTN').load("/src/view/apps.php", function() {
$('#tblApps').DataTable();
});
jUqery.load() Load data from the server and place the returned HTML into the matched elements.
The data loaded will be available only after they are loaded, hence you need to run datatable in the callback.
Change :
function loadApps(){
$('#mainCTN').load("/src/view/apps.php");
$('#tblApps').DataTable();
};
To:
function loadApps(){
$('#mainCTN').load("http://localhost:63342/StackOverflow/1.html", ftion() {
$('#tblApps').DataTable();
});
};

Angular.js return undfined in same code different pages

The application is running on sails.js as backend and Angular as frontend,
It is CRUD application and there two pages, one is the main Dashboard and other is Search.html that have advanced search functionalities.
here the thing two pages, use identical ng-repeat that inject same html page which contain same function with same controller that use same service.
Here how it goes, I click on the delete button which fire showCancelQuoteModal(quote), then I click on the confirmation and fire ng-click=cancelQoute which pass decisionFrom without any problems.
now in cancelQouteModalCtrl both qoute and decisionForm are passed without a problem to qouteLogService, where qoute still there and qoutelog contain cancellationReason.
and qoute.post should return createdQouteLog but it doesn't in search .html and does in Dashboard.html
when I started tracking and watching the var, everything disappear when the code get in Angular.js and the following stack
$scope.apply() / $scope.digest() /$scope.eval() /processQueue()
here the table of Dashboard.html and search.html
<table class="table table-striped table-responsive" ui-jq="footable" data-filter="#filter19"
data-page-size="{{pageControl.pageSize}}">
<thead>
<tr>
<th data-type="date">Last Update</th>
<th>Client</th>
<th>Phone</th>
<th>Dealer</th>
<th>Assigned To</th>
<th data-type="numeric">Status</th>
<th>Progress</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="quote in allQuotes | orderBy: '-updatedAt' track by quote.id"
ng-init="latestQuoteLog=findLatestQuoteLog(quote.quoteLogs)">
<td class="text-center" data-value="{{latestQuoteLog.createdAt}}">
{{latestQuoteLog.createdAt | date : 'dd-MMM-yy hh:mm a'}}
</td>
<td>{{quote.client.name}}</td>
<td>{{quote.client.phone | tel}}</td>
<td ng-if="quote.dealershipCompany">{{quote.dealershipCompany.name}}</td>
<td ng-if="!quote.dealershipCompany">Online</td>
<td>{{username(latestQuoteLog.assignedTo)}}</td>
<td data-value="{{latestQuoteLog.status}}">
<span class="label bg-{{quoteStatusIdToStatusName[latestQuoteLog.status]}}">
{{quoteStatusPrettyNames[latestQuoteLog.status]}}
</span>
</td>
<td>
<div class="progress-xs progress ng-isolate-scope w-sm m-t-sm" type="info">
<div class="progress-bar progress-bar-primary" role="progressbar"
aria-valuenow="{{quoteStatusProgress[latestQuoteLog.status]}}" aria-valuemin="0"
aria-valuemax="100" ng-
style="width: {{quoteStatusProgress[latestQuoteLog.status]}}%;"></div>
</div>
</td>
<td>
<div class=" btn-group">
<button class="btn btn-sm btn-icon btn-default"
ng-if="latestQuoteLog.status != quoteStatus.quoteCancelled"
ng-click="showCancelQuoteModal(quote)">
<i class="glyphicon glyphicon-remove" tooltip="Cancel Quote"></i>
</button>
<button class="btn btn-sm btn-icon btn-default" ng-click="editQuote(quote)">
<i class="glyphicon glyphicon-edit" tooltip="Edit Quote"></i>
</button>
<button class="btn btn-sm btn-icon btn-default" ng-click="viewQuote(quote)">
<i class="glyphicon glyphicon-eye-open" tooltip="View Quote"></i>
</button>
<button class="btn btn-sm btn-icon btn-default"
ng-click="showModal(quote, roles.broker, 'AT', latestQuoteLog)"
ng-if="canAssign(latestQuoteLog, roles.broker)">
<i class="glyphicon glyphicon-arrow-right" tooltip="Assign To Broker"></i>
</button>
<button class="btn btn-sm btn-icon btn-default"
ng-click="showModal(quote, roles.processor, 'AT', latestQuoteLog)"
ng-if="canAssign(latestQuoteLog, roles.processor)">
<i class="glyphicon glyphicon-arrow-right" tooltip="Assign To Processor"></i>
</button>
<button class="btn btn-sm btn-icon btn-default" ng-click="showModal(quote, roles.broker, 'CA')"
ng-if="canChangeAssignee(latestQuoteLog, roles.broker)">
<i class="glyphicon glyphicon-transfer" tooltip="Change Assignee"></i>
</button>
<button class="btn btn-sm btn-icon btn-default"
ng-click="showModal(quote, roles.processor, 'CA')"
ng-if="canChangeAssignee(latestQuoteLog, roles.processor)">
<i class="glyphicon glyphicon-transfer" tooltip="Change Assignee"></i>
</button>
</div>
</td>
</tr>
</tbody>
<tfoot class="hide-if-no-paging">
<tr>
<td colspan="9" class="text-center">
<ul class="pagination"></ul>
</td>
</tr>
</tfoot>
</table>
here cancelModal
<script type="text/ng-template" id="cancelQuoteModal.html">
<div class="modal-header">
<form name="decisionForm" class="form-horizontal wrapper input-set">
<div class="col-md-10">
<label>
<h4 class="font-thin">Why it is not sold ?</h4>
</label>
<select class="form-control" ng-model="reasonForRejection" name="reasonForRejection" required>
<option ng-repeat="reason in rejectionReasons" value="{{reason}}">
{{reason}}
</option>
</select>
<small
ng-show="(decisionForm.reasonForRejection.$invalid && !decisionForm.reasonForRejection.$pristine) || showErrors"
class="b-light m-t-n-sm m-b font-thin text-danger m-r">Reason is required.
</small>
</div>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-sm btn-success" ng-click="cancelQuote(decisionForm)">Confirm Quote Cancellation</button>
<button class="btn btn-warning" ng-click="cancelBox()">Close!</button>
</div>
</script>
Here CancelModalController
.controller('cancelQuoteModalCtrl', ['$scope', '$modalInstance', 'quoteLogService', 'rejectionReasons', 'quote', function ($scope, $modalInstance, quoteLogService, rejectionReasons, quote) {
$scope.rejectionReasons = rejectionReasons;
$scope.reasonForRejection;
$scope.cancelQuote = function (decisionForm) {
if (decisionForm.$invalid) {
$scope.showErrors = true;
} else {
quoteLogService.create(quote, {
'status': 'quoteCancelled',
'cancellationReason': $scope.reasonForRejection
}, function (createdQuoteLog) {
$modalInstance.close('Quote cancelled successfully!');
}, function (err) {
$modalInstance.dismiss('Error creating new quoteLog');
console.log('Error creating new quoteLog', err);
});
}
};
$scope.cancelBox = function () {
$modalInstance.close();
};
}]);
And here QouteLogService.js
QuoteLogModule
.factory('quoteLogService', ['$localStorage', '$state', 'LoggedInRestangular', function($localStorage, $state, LoggedInRestangular) {
return {
create: function(quote, quotelog, success, error) {
quote.post('quotelog', quotelog).then(function(createdQuoteLog) {
success(createdQuoteLog);
}, function(err) {
error(err);
});
},

On xeditable grid where move a cursor same column when user press the Tab key

I'm using Xeditable grid.Could you tell me how to move a cursor same column when user press the Tab key ? i.e move on Name column.Thanks in advance.
JSFiddle
Note : By default it moves horizontally on the row.I need it moves vertically on the column.
<h4>Angular-xeditable Editable table (Bootstrap 3)</h4>
<div ng-app="app" ng-controller="Ctrl">
<form editable-form name="tableform" onaftersave="saveTable()" oncancel="cancel()" shown="true">
<!-- table -->
<table class="table table-bordered table-hover table-condensed">
<tr style="font-weight: bold">
<td style="width:40%">Name</td>
<td style="width:30%">Status</td>
<td style="width:30%">Group</td>
<td style="width:30%"><span ng-show="tableform.$visible">Action</span></td>
</tr>
<tr ng-repeat="user in users | filter:filterUser">
<td>
<!-- editable username (text with validation) -->
<span editable-text="user.name" e-form="tableform" onbeforesave="checkName($data, user.id)">
{{ user.name || 'empty' }}
</span>
</td>
<td>
<!-- editable status (select-local) -->
<span editable-select="user.status" e-form="tableform" e-ng-options="s.value as s.text for s in statuses">
{{ showStatus(user) }}
</span>
</td>
<td>
<!-- editable group (select-remote) -->
<span editable-select="user.group" e-form="tableform" onshow="loadGroups()" e-ng-options="g.id as g.text for g in groups">
{{ showGroup(user) }}
</span>
</td>
<td><button type="button" ng-show="tableform.$visible" ng-click="deleteUser(user.id)" class="btn btn-danger pull-right">Del</button></td>
</tr>
</table>
<!-- buttons -->
<div class="btn-edit">
<button type="button" class="btn btn-default" ng-show="!tableform.$visible" ng-click="tableform.$show()">
edit
</button>
</div>
<div class="btn-form" ng-show="tableform.$visible">
<button type="button" ng-disabled="tableform.$waiting" ng-click="addUser()" class="btn btn-default pull-right">add row</button>
<button type="submit" ng-disabled="tableform.$waiting" class="btn btn-primary">save</button>
<button type="button" ng-disabled="tableform.$waiting" ng-click="tableform.$cancel()" class="btn btn-default">cancel</button>
</div>
</form>
</div>
You need to add e-tabindex to your columns like this.
<tr ng-repeat="user in users | filter:filterUser">
<td>
<!-- editable username (text with validation) -->
<span editable-text="user.name" e-form="tableform" onbeforesave="checkName($data, user.id)" e-tabindex="1">
{{ user.name || 'empty' }}
</span>
</td>
<td>
<!-- editable status (select-local) -->
<span editable-select="user.status" e-form="tableform" e-ng-options="s.value as s.text for s in statuses" e-tabindex="2">
{{ showStatus(user) }}
</span>
</td>
<td>
<!-- editable group (select-remote) -->
<span editable-select="user.group" e-form="tableform" onshow="loadGroups()" e-ng-options="g.id as g.text for g in groups" e-tabindex="3">
{{ showGroup(user) }}
</span>
</td>
<td><button type="button" ng-show="tableform.$visible" ng-click="deleteUser(user.id)" class="btn btn-danger pull-right" tabindex="4">Del</button></td>
</tr>

Categories