Can the right column be fixed in the bootstrap-vue table? - vue.js

I want right fixed columns in the bootstrap-vue table
but, the Sticky function in the document is only fixed to the left.
Is there a way to fix the right side or last columns?
I want both the left and right columns being fixed in place.
documnet : https://bootstrap-vue.org/docs/components/table#sticky-columns
<template>
<div>
<div class="mb-2">
<b-form-checkbox v-model="stickyHeader" inline>Sticky header</b-form-checkbox>
<b-form-checkbox v-model="noCollapse" inline>No border collapse</b-form-checkbox>
</div>
<b-table
:sticky-header="stickyHeader"
:no-border-collapse="noCollapse"
responsive
:items="items"
:fields="fields"
>
<!-- We are using utility class `text-nowrap` to help illustrate horizontal scrolling -->
<template #head(id)="scope">
<div class="text-nowrap">Row ID</div>
</template>
<template #head()="scope">
<div class="text-nowrap">
Heading {{ scope.label }}
</div>
</template>
</b-table>
</div>
</template>
<script>
export default {
data() {
return {
stickyHeader: true,
noCollapse: false,
fields: [
{ key: 'id', stickyColumn: true, isRowHeader: true, variant: 'primary' },
'a',
'b',
{ key: 'c', stickyColumn: true, variant: 'info' },
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l'
],
items: [
{ id: 1, a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6, h: 7, i: 8, j: 9, k: 10, l: 11 },
{ id: 2, a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6, h: 7, i: 8, j: 9, k: 10, l: 11 },
{ id: 3, a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6, h: 7, i: 8, j: 9, k: 10, l: 11 },
{ id: 4, a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6, h: 7, i: 8, j: 9, k: 10, l: 11 },
{ id: 5, a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6, h: 7, i: 8, j: 9, k: 10, l: 11 },
{ id: 6, a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6, h: 7, i: 8, j: 9, k: 10, l: 11 },
{ id: 7, a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6, h: 7, i: 8, j: 9, k: 10, l: 11 },
{ id: 8, a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6, h: 7, i: 8, j: 9, k: 10, l: 11 },
{ id: 9, a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6, h: 7, i: 8, j: 9, k: 10, l: 11 },
{ id: 10, a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6, h: 7, i: 8, j: 9, k: 10, l: 11 }
]
}
}
}
</script>

It's possible by overriding bootstrap's CSS with some of our own. First make sure the last column has the stickyColumn: true option plus whatever other options you want to give it:
...
'i',
'j',
'k',
{ key: "l", stickyColumn: true, isRowHeader: true, variant: "primary" },
This will ensure it has a classname we can easily select on. Apply styling that gives the last sticky column in the table an attribute of right: 0:
<style>
.b-table-sticky-column:last-child {
right: 0;
}
</style>
codesandbox example

Related

Filtering numbers or strings in a comma delimited object

I am using multi-select to filter out data.
<Multiselect
v-model="roles"
class="input1"
placeholder="Select Roles"
mode="tags"
:searchable="true"
:options="roleOptions"
/>
<Multiselect
v-model="sub_organization"
class="input1"
placeholder="Select sub-organization"
mode="tags"
:searchable="true"
:options="suborgOptions"
/>
data:() => ({
mode: "tags",
closeOnSelect: false,
roleOptions: [],
suborgOptions: [],
searchable: true,
sub_organization: [],
roles: [],
filteredData: [],
fetchedData: [],
}),
searchResult() {
this.filteredData = this.fetchedData.filter((data) => {
// var intRoles = parseInt(data.roles.split(", "))
// var intSuborgs = parseInt(data.suborgs.split(", "))
return (
// intSuborgs == this.sub_organization &&
// intRoles == this.roles
data.suborgs.includes(this.sub_organization) &&
data.roles.includes(this.roles)
);
});
},
data.roles = {1, 3},
{1, 4, 5, 7},
{10, 14},
{1, 9},
{2, 4, 6, 8},
{4, 5},
{4, 10},
{9, 1, 4}
for example:
when I use includes and I searched 1 it returns all data.roles with 1 in it including 10, 14, 4, 10 etc.
using includes():
searching 1 returns {1, 3}, {1, 4, 5, 7}, {10, 14}, {1, 9}, {4, 10}, {9, 1, 4}
searching 4 returns {1, 4, 5, 7}, {10, 14}, {4, 10}, {9, 1, 4}, {4, 5}, {2, 4, 6, 8}
as you can see I commented out intRoles and intSuborgs, I tried using parseInt and then split it, when I search 1 it returns only the objects that have 1 in index 0
using parseInt and split:
searching 1 returns {1, 3}, {1, 4, 5, 7}, {1, 9}
searching 4 returns {4, 5}, {4, 10},
What I want to happen is when I search 1 it would return only the objects that has 1 in it excluding double digits with 1, or since I am using multi-select searching 1 and 4 returns objects with 1 and 4 in it excluding double digits with 1 and 4 also.

Can help make array with only odd numbers from array in Kotlin

I need help. I trying make array only with odd numbers but I don't want use arraylist because I only want array.
Input array like this: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
I am trying to get odd only array like : [1, 3, 5, 7, 9]
val array = arrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
val arraylist = arrayListOf<Int>()
for(i in 0..array.size - 1) {
if(array[i] % 2 != 0)
arraylist.add(array[i])
}
val oddarray = arraylist.toArray()
Why not just use filter:
import java.util.Arrays;
fun main(args: Array<String>) {
val numbersArray = arrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
val oddArray = numbersArray.filter{ it % 2 != 0 }.toTypedArray()
print(Arrays.toString(oddArray)) // [1, 3, 5, 7, 9]
}

objective-c equivalent to group by in groovy

Source array:
[ { a: 1, b: 1}, { a: 1, b: 2}, { a: 2, b: 3} ]
Target dictionary:
{ 1: [{a: 1, b: 1}, {a: 1, b: 2}], 2: [{ a: 2, b: 3}] }
So i want to have the objects in the source array grouped by their value of a.
In groovy it's done using array.groupBy({ it.a }). Is there a nice equivalent in objective-c?

Line Chart with Int as x axis, not Date

I would like to display a chart which shows integers on the x axis instead of dates.
Here is a fiddle of the example:
http://jsfiddle.net/cs3vigny/srmqcfjh/
new Morris.Line({
element: 'film-compare-chart',
data: [
{ week: 0, a: 2, b: 4, c: 5, d: 3, e: 3 },
{ week: 1, a: 2, b: 3, c: 6, d: 3, e: 3 },
{ week: 2, a: 3, b: 5, c: 4, d: 2, e: 2 },
{ week: 3, a: 3, b: 6, c: 6, d: 3, e: 4 },
{ week: 4, a: 4, b: 4, c: 5, d: 4, e: 2 },
{ week: 5, a: 4, b: 6, c: 6, d: 3, e: 2 },
{ week: 6, a: 4, b: 7, c: 8, d: 5, e: 2 },
{ week: 7, a: 3, b: 5, c: 6, d: 5, e: 4 },
{ week: 8, a: 4, b: 8, c: 6, d: 4, e: 3 },
{ week: 9, a: 6, b: 10, c: 8, d: 7, e: 5 },
{ week: 10, a: 5, b: 12, c: 13, d: 7, e: 4 },
{ week: 11, a: 6, b: 10, c: 10, d: 7, e: 4 },
{ week: 12, a: 9, b: 10, c: 10, d: 10, e: 6 },
{ week: 13, a: 11, b: 15, c: 16, d: 12, e: 9 },
{ week: 14, a: 14, b: 15, c: 14, d: 13, e: 10 },
{ week: 15, a: 14, b: 20, c: 17, d: 15, e: 11 },
{ week: 16, a: 18, b: 26, c: 22, d: 16, e: 15 },
{ week: 17, a: 19, b: 22, c: 22, d: 18, e: 13 },
{ week: 18, a: 19, b: 21, c: 25, d: 20, e: 16 },
{ week: 19, a: 26, b: 26, c: 33, d: 24, e: 21 },
{ week: 20, a: 26, b: 26, c: 31, d: 24, e: 21 },
{ week: 21, a: 24, b: 28, c: 41, d: 26, e: 22 },
{ week: 22, a: 33, b: 32, c: 40, d: 29, e: 28 },
{ week: 23, a: 34, b: 37, c: 51, d: 34, e: 32 }
],
xkey: 'week',
ykeys: ['a','b','c','d','e'],
labels: ['Cinderella (2015)', 'Maleficent', 'Oz: The Great and Powerful', 'Divergent', 'Big Hero 6']
});
Does Morris.js only display dates on the x-axis no matter what or can that be changed?
Try adding option parameter parseTime:false.
In Morrischart,if 'parseTime' set to false then it skip time/date parsing for X values, Otherwise it treating them as an equally-spaced series;the default value is parseTime:true..thats why you get confused..So could you please insert the below line of code
parseTime:false
sample code like as follows,
new Morris.Area({
------
parseTime:false,
------
});
Hope its works fine :-)

Compiler gives "excess element in array initializer" warning in objective C with 2D C-array

I'm just learning Objective C and writing a program to aid people in learning to play the guitar. I wanted to create a 2D array containing (almost) all the notes on a guitar neck. Since there are six strings on the guitar and twelve notes in an octave, I created a 6 x 12 array. EDIT: solution is now at bottom
The intention here is for the array to be read as (string),(fret number).
int strings[6][12] = {
{ {0, 8},{0, 9},{0, 10},{0, 11} ,{0, 12} ,{0, 1}, {0, 2},{0, 3},{0, 4},{0, 5},{0, 6},{0, 7} },
{ {1, 3},{1, 4},{1, 5},{1, 6},{1, 7},{1, 8,},{1, 9},{1, 10},{1, 11} ,{1, 12},{1, 1},{1, 2} },
{ {2, 12},{2, 1},{2, 2},{2, 3},{2, 4},{2, 5},{2, 6},{2, 7},{2, 8},{2, 9},{2, 10},{2, 11} },
{ {3, 6}, {3, 7} , {3, 8} , {3, 9} ,{3, 10} ,{3, 11} ,{3, 12} ,{3, 1} ,{3, 2} ,{3, 3} ,{3, 4} ,{3, 5} },
{ {4, 1} ,{4, 2} ,{4, 3} ,{4, 4} ,{4, 5} ,{4, 6} ,{4, 7} ,{4, 8} ,{4, 9} , {4, 10} ,{4, 11} ,{4, 12} },
{ {5, 9},{5, 10},{5, 11} , {5, 12} ,{5, 1},{5, 2},{5, 3},{5, 4},{5, 5},{5, 6},{5, 7},{5, 8} }
};
The problem is, XCode throws an warning: "excess elements in array initializer." What am I doing wrong? I've counted the elements numerous times and still am left scratching my head.
Moved from the question to an actual answer post:
Thanks to you cool people, I figured out the problem. In the event
someone else has this problem, here is my solution. I came to realize
that the problem was that I had two integers assigned in each array
slot, effectively making the array a 3D array. Since the first number
in each pair is just the string number, I went ahead and just got rid
of it. No more warnings!**
int strings[6][12] = {8, 9, 10, 11, 12, 1 ,2 ,3, 4, 5, 6, 7, // High e
3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, // B
12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, //G
6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, // D
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, // A
8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7 }; // E