How to make set of mat-card containing different charts have drag and drop feature and auto align - drag-and-drop

HTML
<div class="boundary">
<div cdkDrag fxLayout="row wrap" fxLayoutGap="15px" cdkDropListOrientation="horizontal" cdkDropList (cdkDropListDropped)="drop($event)" [cdkDropData]="list">
<div *ngFor="let li of list" [cdkDragData]="li" cdkDrag cdkDragBoundary=".boundary">
<div cdkDragBoundary=".boundary" class="mt_15" *ngIf="li == 1">
<mat-card matBadge="2" matBadgeColor="warn" matBadgeOverlap="true">
<div style="display: block">
<canvas baseChart [data]="pieChartData0" [labels]="pieChartLabels" [chartType]="pieChartType"
[options]="pieChartOptions" [colors]="pieChartColors"></canvas>
</div>
</mat-card>
</div>
<div cdkDragBoundary=".boundary" class="mt_15" *ngIf="li == 2">
<mat-card>
<div style="display: block">
<canvas baseChart [data]="pieChartData1" [labels]="pieChartLabels" [chartType]="pieChartType"
[options]="pieChartOptions" [colors]="pieChartColors"></canvas>
</div>
</mat-card>
</div>
<div cdkDragBoundary=".boundary" class="mt_15" *ngIf="li == 3">
<mat-card matBadge="1" matBadgeColor="warn" matBadgeOverlap="true">
<div style="display: block">
<canvas baseChart [data]="pieChartData2" [labels]="pieChartLabels" [chartType]="pieChartType"
[options]="pieChartOptions" [colors]="pieChartColors"></canvas>
</div>
</mat-card>
</div>
<div cdkDragBoundary=".boundary" class="mt_15" *ngIf="li == 4">
<mat-card>
<div style="display: block">
<canvas baseChart [data]="pieChartData3" [labels]="pieChartLabels" [chartType]="pieChartType"
[options]="pieChartOptions" [colors]="pieChartColors"></canvas>
</div>
</mat-card>
</div>
<div cdkDragBoundary=".boundary" class="mt_15" *ngIf="li == 5">
<mat-card>
<div style="display: block">
<canvas baseChart [data]="pieChartData4" [labels]="pieChartLabels" [chartType]="pieChartType"
[options]="pieChartOptions" [colors]="pieChartColors"></canvas>
</div>
</mat-card>
</div>
<div cdkDragBoundary=".boundary" class="mt_15" *ngIf="li == 6">
<mat-card>
<div style="display: block">
<canvas baseChart [data]="pieChartData4" [labels]="pieChartLabels" [chartType]="pieChartType"
[options]="pieChartOptions" [colors]="pieChartColors"></canvas>
</div>
</mat-card>
</div>
<div cdkDragBoundary=".boundary" class="mt_15" *ngIf="li == 7">
<mat-card>
<div style="display: block">
<canvas baseChart [data]="pieChartData4" [labels]="pieChartLabels" [chartType]="pieChartType"
[options]="pieChartOptions" [colors]="pieChartColors"></canvas>
</div>
</mat-card>
</div>
<div cdkDragBoundary=".boundary" class="mt_15" *ngIf="li == 8">
<mat-card>
<div style="display: block">
<canvas baseChart [data]="pieChartData4" [labels]="pieChartLabels" [chartType]="pieChartType"
[options]="pieChartOptions" [colors]="pieChartColors"></canvas>
</div>
</mat-card>
</div>
</div>
</div>
</div>
TS
import { Component, OnInit, ViewChild } from '#angular/core';
import { ChartType, ChartOptions, Chart } from 'chart.js';
import { Label } from 'ng2-charts';
#Component({
selector: 'app-dashboard',
templateUrl: './dashboard.component.html',
styleUrls: ['./dashboard.component.scss']
})
export class DashboardComponent implements OnInit {
list = [1, 2, 3, 4, 5, 6, 7, 8];
pieChartOptions: ChartOptions;
pieChartLabels: Label[];
pieChartData0: number[];
pieChartData1: number[];
pieChartData2: number[];
pieChartData3: number[];
pieChartData4: number[];
pieChartType: ChartType;
pieChartLegend: boolean;
pieChartPlugins = [];
pieChartColors = []
constructor( ) { }
ngOnInit(): void {
Chart.plugins.register
this.pieChartOptions = this.createOptions()
this.pieChartLabels = ['Abnormal', 'Warning', 'No Abnormality'];
this.pieChartData0 = [2, 0, 8];
this.pieChartData1 = [0, 0, 10];
this.pieChartData2 = [2, 5, 3];
this.pieChartData3 = [2, 0, 8];
this.pieChartData4 = [0, 0, 10];
this.pieChartType = 'pie';
// this.pieChartPlugins = [pluginLabels];
// this.pieChartLegend = true
this.pieChartColors = [
{
backgroundColor: ['orange', 'darkorange', 'lightblue'],
}
];
}
private createOptions(): ChartOptions {
return {
responsive: true,
// maintainAspectRatio: false,
legend: {
display: false,
labels: {
padding: 10,
boxWidth: 13,
},
position: 'bottom',
},
plugins: {
labels: {
render: 'value',
fontSize: 16,
position: 'center',
fontStyle: '500',
fontFamily: "'Roboto', 'Helvetica Neue', 'sans-serif'",
precision: 2
},
}
}
}
drop(event: CdkDragDrop<string[]>) {
moveItemInArray(this.list, event.previousIndex, event.currentIndex);
}
}
I'm able to achieve drag and drop but auto alignment is not working based on the id for each div.
I took the reference from the following link Drag-Drop
Using the reference it's achieavable to just drag anywhere, but as I want it should be within certain space for which I used class i.e boundary.
Also since I'm not able to get the card as dynamic so I'm using *ngIf contion.
If anyone have any suggestion or reference that would be of much help.

Related

VueJS form item json post

I have a form and when the "new iban" button is clicked in this form, he can add as many "iban" inputs as he wants.
in the same way, when the "add item" button is clicked, as many entries can be added and "SPINNET" can be seen. But when I post them, the input values ​​return empty. I want it to be sent in "iban" and "authoritative" json format.
new Vue({
el: "#app",
data() {
return {
data: {
name: "",
iban: "",
yetkili: "",
},
sections: [{
ibans: [{
item: ""
}]
}],
yetkisection: [{
yetkililer: [{
yetkiliadi: "",
yetkilieposta: "",
yetkilitelefon: "",
yetkilinotu: "",
}]
}],
}
},
methods: {
addNewItem(id) {
this.sections[id].ibans.push({
item: ''
});
},
removeItem(sectionIndex, ibanIndex) {
this.sections[sectionIndex].ibans.splice(ibanIndex, 1);
},
addNewYetkili(id) {
this.yetkisection[id].yetkililer.push({
yetkiliadi: ''
});
},
removeYetkili(sectionIndex, ibanIndex) {
this.yetkisection[sectionIndex].yetkililer.splice(ibanIndex, 1);
},
async addTag() {
const res = await this.callApi('post', 'app/create_musteri', this.data)
if (res.status === 200) {
console.log(res)
} else {
console.log("error");
}
}
},
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<template>
<div class="container">
<div class="col-12">
<div class="mb-1 row">
<div class="col-sm-3">
<label class="col-form-label"><span><i data-feather='file-text'></i></span>NAME</label>
</div>
<div class="col-sm-6">
<input type="text" class="form-control" placeholder="Item" v-model="data.name">
</div>
</div>
</div>
<div class="col-12 sections" v-for="(section, sectionIndex) in sections">
<div class="mb-1 row" v-for="(iban, ibanIndex) in section.ibans">
<div class="col-sm-3">
<label class="col-form-label" for="iban"><span><i data-feather='file-text'></i></span>IBAN NUMBER</label>
</div>
<div class="col-sm-6">
<input type="text" class="form-control" placeholder="Item" v-model="iban.item">
<span v-if="section.ibans.length>1"
class="float-right" style="cursor:pointer" #click="removeItem(sectionIndex, ibanIndex)">X</span>
</div>
</div>
<button class="btn btn-success mt-5 mb-5" #click="addNewItem(sectionIndex)">New Iban</button>
</div>
<div>
<div>
<table class="fatura-table">
<colgroup>
<col style="width: 25%;;">
<col style="width: 25%;;">
<col style="width: 25%;;">
<col style="width: ;">
<col style="width: 70px;">
</colgroup>
<thead>
<tr>
<th>YETKİLİ KİŞİNİN ADI</th>
<th>E-POSTA</th>
<th>TELEFON</th>
<th>NOTLAR</th>
<th></th>
</tr>
</thead>
</table>
</div>
<section v-for="(section, sectionIndex) in yetkisection">
<div class="card-body" v-for="(yetkili, ibanIndex) in section.yetkililer">
<div class="row">
<div class="col-sm-3 col-12 mb-1 mb-sm-0 hizmet">
<div class="form-floating">
<input type="text" class="form-control" v-model="yetkili.yetkiliadi" placeholder=" "/>
<label>YETKİLİ KİŞİNİN ADI</label>
</div>
</div>
<div class="col-sm-3 col-12 mb-1 mb-sm-0 hizmet">
<div class="form-floating">
<input type="text" class="form-control" v-model="yetkili.yetkilieposta" placeholder=" "/>
<label>E-POSTA</label>
</div>
</div>
<div class="col-sm-2 col-12 mb-1 mb-sm-0 hizmet">
<div class="form-floating">
<input type="text" class="form-control" v-model="yetkili.yetkilitelefon" placeholder=" "/>
<label>TELEFON</label>
</div>
</div>
<div class="col-sm-3 col-12 mb-1 mb-sm-0 hizmet">
<div class="form-floating">
<input type="text" class="form-control" v-model="yetkili.yetkilinotu" placeholder=" "/>
<label>NOTLAR</label>
</div>
</div>
<div class="col-sm-1 col-12 mb-1 mb-sm-0">
<button class="btn btn-icon btn-secondary waves-effect waves-float waves-light" #click="removeYetkili(sectionIndex, ibanIndex)">
<i data-feather='x'>DELETE</i>
</button>
</div>
</div>
</div>
<div class="mt-1">
<div class="col-12 px-0">
<button type="button" class="btn btn-primary btn-sm btn-add-new" data-repeater-create #click="addNewYetkili(sectionIndex)">
<i data-feather="plus" class="me-25"></i>
<span class="align-middle">Add Item</span>
</button>
</div>
</div>
</section>
</div>
<button #click="addTag" class="btn btn-dark data-submit">SAVE</button>
</div>
</template>
</div>
Edited my answer to handle your new build and structure.
Showing both the approaches below:
new Vue({
el: "#app",
data() {
return {
data: {
name: "",
iban: "",
yetkili: ""
},
sections: [{ item: "" }],
yetkisections: [
{
yetkiliadi: "",
yetkilieposta: "",
yetkilitelefon: "",
yetkilinotu: ""
}
]
};
},
methods: {
addNewItem() {
this.sections.push({ item: "" });
},
removeItem(sectionIndex) {
this.sections.splice(sectionIndex, 1);
},
addNewYetkili() {
this.yetkisections.push({ yetkiliadi: "" });
},
removeYetkili(yetkisectionIndex) {
this.yetkisections.splice(yetkisectionIndex, 1);
},
async addTag() {
/* const res = await this.callApi('post', 'app/create_musteri', this.formData)
if (res.status === 200) {
console.log(res)}
else {
console.log("error");
} */
console.log(this.$data);
console.log(this.formData);
}
},
computed: {
formData() {
return {
data: {
...this.data,
sections: this.sections,
yetkisection: this.yetkisections
}
};
}
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<template>
<div class="container">
<div class="col-12">
<div class="mb-1 row">
<div class="col-sm-3">
<label class="col-form-label"
><span><i data-feather="file-text"></i></span>NAME</label
>
</div>
<div class="col-sm-6">
<input
type="text"
class="form-control"
placeholder="Item"
v-model="data.name"
/>
</div>
</div>
</div>
<div
class="col-12 sections"
v-for="(section, sectionIndex) in sections"
:key="sectionIndex"
>
<div class="col-sm-3">
<label class="col-form-label" for="iban"
><span><i data-feather="file-text"></i></span>IBAN NUMBER</label
>
</div>
<div class="col-sm-6">
<input
type="text"
class="form-control"
placeholder="Item"
v-model="section.item"
/>
<span
v-if="sections.length > 1"
class="float-right"
style="cursor: pointer"
#click="removeItem(sectionIndex)"
>X</span
>
</div>
</div>
<button class="btn btn-success mt-5 mb-5" #click="addNewItem()">
New Iban
</button>
<div>
<div>
<table class="fatura-table">
<colgroup>
<col style="width: 25%;;" />
<col style="width: 25%;;" />
<col style="width: 25%;;" />
<col style="width: ;" />
<col style="width: 70px;" />
</colgroup>
<thead>
<tr>
<th>YETKİLİ KİŞİNİN ADI</th>
<th>E-POSTA</th>
<th>TELEFON</th>
<th>NOTLAR</th>
<th></th>
</tr>
</thead>
</table>
</div>
<section>
<div
class="card-body"
v-for="(yetkili, yetkisectionIndex) in yetkisections"
:key="yetkisectionIndex"
>
<div class="row">
<div class="col-sm-3 col-12 mb-1 mb-sm-0 hizmet">
<div class="form-floating">
<input
type="text"
class="form-control"
v-model="yetkili.yetkiliadi"
placeholder=" "
/>
<label>YETKİLİ KİŞİNİN ADI</label>
</div>
</div>
<div class="col-sm-3 col-12 mb-1 mb-sm-0 hizmet">
<div class="form-floating">
<input
type="text"
class="form-control"
v-model="yetkili.yetkilieposta"
placeholder=" "
/>
<label>E-POSTA</label>
</div>
</div>
<div class="col-sm-2 col-12 mb-1 mb-sm-0 hizmet">
<div class="form-floating">
<input
type="text"
class="form-control"
v-model="yetkili.yetkilitelefon"
placeholder=" "
/>
<label>TELEFON</label>
</div>
</div>
<div class="col-sm-3 col-12 mb-1 mb-sm-0 hizmet">
<div class="form-floating">
<input
type="text"
class="form-control"
v-model="yetkili.yetkilinotu"
placeholder=" "
/>
<label>NOTLAR</label>
</div>
</div>
<div class="col-sm-1 col-12 mb-1 mb-sm-0">
<button
class="btn btn-icon btn-secondary waves-effect waves-float waves-light"
#click="removeYetkili(yetkisectionIndex)"
>
<i data-feather="x">DELETE</i>
</button>
</div>
</div>
</div>
<div class="mt-1">
<div class="col-12 px-0">
<button
type="button"
class="btn btn-primary btn-sm btn-add-new"
data-repeater-create
#click="addNewYetkili()"
>
<i data-feather="plus" class="me-25"></i>
<span class="align-middle">Add Item</span>
</button>
</div>
</div>
</section>
</div>
<button #click="addTag" class="btn btn-dark data-submit">SAVE</button>
</div>
</template>
</div>

Using a form on a knockout.js template

I have a knockout template that is successfully receiving data. I added a form to the template with a text input and a submit input and bound an observable view model property within the text input.
When bind the text input value to the view model property ( the incoming data is lost and the button doesn't work. I'm dumping the incoming data before and after the input tag and the data is gone on the second dump.
Following is the template code snippet:
<div class="container">
<div style="width:100%;">
<div class="panel panel-primary" style="max-width:700px; margin:0 auto;">
<div class="panel panel-heading" style="text-align:right">
<i class="fa fa-sign-out"></i> Logout
</div>
<ul class="nav nav-tabs" data-bind="foreach: tabs">
<li data-bind="css: { active: isSelected }">
<span data-bind="html: name" />
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" data-bind="template: { name: getTemplate, data: getTemplateData }"></div>
</div>
</div>
</div>
</div>
<script id="0" type="text/html">
<br />
<div class="row" style="margin-left:1px; margin-right:5px; margin-top:10px; margin-bottom:10px;">
<form>
<div>
<pre data-bind="text: JSON.stringify(ko.toJS($data), null, 2)"></pre>
<input type="text" data-bind="value: $parent.cameraName, valueUpdate: 'afterkeydown'" placeholder="New Camera Name..." />
<pre data-bind="text: JSON.stringify(ko.toJS($data), null, 2)"></pre>
<input type="submit" data-bind="click: $parent.addCamera" value="ADD" />
</div>
</form>
</div>
<div data-bind="foreach: $data">
<div class="rounded-radius-5">
Name: <span class="spaces" data-bind="text: name"></span> |
<span class="spaces"></span>
Job: <span class="spaces" data-bind="text: job"></span> |
<span class="spaces"></span>
Status: <span data-bind="style: { color: textColor }"><span class="spaces" data-bind="text: status"></span></span>
<div style="text-align:right; float: right"><span class="glyphicon glyphicon-trash"></span></div>
</div>
</div>
</script>
Following is the json dump:
[
{
"cameraid": 1,
"name": "WS-LICAM01",
"job": "100",
"status": "CheckedOut",
"textColor": "#FF0000"
},
{
"cameraid": 2,
"name": "WS-LICAM02",
"job": "916",
"status": "CheckedOut",
"textColor": "#FF0000"
},
{
"cameraid": 3,
"name": "WS-LICAM03",
"job": "956",
"status": "CheckedOut",
"textColor": "#FF0000"
},
{
"cameraid": 4,
"name": "WS-LICAM04",
"job": "956",
"status": "CheckedOut",
"textColor": "#FF0000"
},
{
"cameraid": 5,
"name": "WS-LICAM05",
"job": "9999",
"status": "CheckedOut",
"textColor": "#FF0000"
}
]
Can anyone help with this issue or let me know a better way?
Well, I found an ugly way of submitting the form without trashing my incoming data.
Here is my new form:
<script id="0" type="text/html">
<div class="row" style="margin-left:1px; margin-right:5px; margin-top:10px; margin-bottom:10px;">
<form data-bind="submit: $parent.addCamera">
<input type="text" name="tbxCamera" id="tbxCamera" placeholder="New Camera Name..." />
<button type="submit">ADD</button>
</form>
</div>
<br />
<div><p><h4>Checked Out</h4></p></div>
<div style="overflow-y:scroll; height:auto; max-height:160px;">
<div data-bind="foreach: $data">
<!-- ko if: checkedOut -->
<div class="rounded-radius-5">
Name: <span class="spaces" data-bind="text: name"></span> |
<span class="spaces"></span>
Job: <span class="spaces" data-bind="text: job"></span> |
<span class="spaces"></span>
Status: <span data-bind="style: { color: textColor }"><span class="spaces" data-bind="text: status"></span></span>
<div style="text-align:right; float: right"><span class="glyphicon glyphicon-trash"></span></div>
</div>
<!-- /ko -->
</div>
</div>
<br />
<div><p><h4>Checked In</h4></p></div>
<div style="overflow-y:scroll; height:auto; max-height:160px;">
<div data-bind="foreach: $data">
<!-- ko ifnot: checkedOut -->
<div class="rounded-radius-5">
Name: <span class="spaces" data-bind="text: name"></span> |
<span class="spaces"></span>
Job: <span class="spaces" data-bind="text: job"></span> |
<span class="spaces"></span>
Status: <span data-bind="style: { color: textColor }"><span class="spaces" data-bind="text: status"></span></span>
<div style="text-align:right; float: right"><span class="glyphicon glyphicon-trash"></span></div>
</div>
<!-- /ko -->
</div>
</div>
</script>
The value from the form is extracted in my ViewModel as follows:
NOTE: data[0] is the text input and data[1] is the button. I'm only using the text input
self.addCamera = function (data, event) {
var newCamera = [{
CameraId: 6,
Name: data[0].value,
Job: 'N/A',
Status: 'CheckedIn'
}];
self.cameras($.map(newCamera, function (item) {
return new camera(item);
}));
};

How to achieve nested lists with rubaxa sortable.js

I'm using Rubaxas Sortable.js to be able to sort lists.
My problem is that i can only move the ".group_container" to the bottom of the main holder but not inbetween the other lists.
Heres a jsFiddle https://jsfiddle.net/adishardis/6csou39n/4/
<h1>Sortable</h1>
<div class="group" id="main">
<div class="group group_container" id="group1">
a
<div class="question">item 1</div>
<div class="question">item 2</div>
<div class="question">item 3</div>
</div>
<div class="group group_container" id="group2">
b
<div class="question">item 4</div>
<div class="question">item 5</div>
<div class="question">item 6</div>
</div>
<div class="group group_container" id="group3">
c
<div class="question">item 7</div>
<div class="question">item 8</div>
<div class="question">item 9</div>
</div>
</div>
What am I missing?
This is actually quite simple, all you need is a group in your options to allow the sortable objects to be within the same context.
// Simple list
var opts = {
group: 'shared',
draggable: '.question',
group: 'foo'
};
var opts2 = {
draggable: '.group_container',
group: 'foo'
};
Enjoy!
This worked for me. First, all divs should have both class group and group_container.
Finally, the Javascript should be like this:
// Simple list
var opts = {
group: 'shared',
draggable: '.group_container',
animation: 50,
fallbackOnBody: true,
wapThreshold:.5
};
var opts2 = {
group: 'shared',
draggable: '.group_container'
};
document.querySelectorAll("#main .group").forEach((e)=>Sortable.create(e, opts))
var el = document.getElementById('main');
var sortable = Sortable.create(el, opts2);
With this, each div tag is draggable and also can receive new elements in it.
Live example:
// Simple list
var opts = {
group: 'shared',
draggable: '.group_container',
animation: 50,
fallbackOnBody: true,
swapThreshold:.5
};
var opts2 = {
group: 'shared',
draggable: '.group_container'
};
document.querySelectorAll("#main .group").forEach((e)=>Sortable.create(e, opts))
var el = document.getElementById('main');
var sortable = Sortable.create(el, opts2);
body {
margin: 10px;
}
.glyphicon-move {
cursor: move;
cursor: -webkit-grabbing;
}
.item {
padding: 1em;
margin-bottom: .2em;
background: rgba(120, 255, 120, 0.8);
cursor: move;
}
.question {
padding: 0.5em;
margin-bottom: .2em;
background: #fff;
cursor: move;
}
.group {
padding: 1em;
margin-bottom: 1em;
background: #ddd;
cursor: move;
}
.group_container {
padding: 1em;
margin-bottom: 1em;
background: rgba(255, 120, 120, 0.2);
cursor: move;
}
.item.group {
background: rgba(120, 120, 255, 0.2);
cursor: move;
}
<script type="text/javascript" src="https://rawgit.com/RubaXa/Sortable/master/Sortable.min.js"></script>
<h1>Sortable</h1>
<div class="group" id="main">
<div class="group group_container" id="group1">
a
<div class="group group_container">item 1</div>
<div class="group group_container">item 2</div>
<div class="group group_container">item 3</div>
</div>
<div class="group group_container" id="group2">
b
<div class="group group_container">item 4</div>
<div class="group group_container">item 5</div>
<div class="group group_container">item 6</div>
</div>
<div class="group group_container" id="group3">
c
<div class="group group_container">item 7</div>
<div class="group group_container">item 8</div>
<div class="group group_container">item 9</div>
</div>
</div>
Regards.

Materialize CSS - Collapsible & Date Input

I have problem with materialize collapsible and date picker. Collapsible is not even opening on click and the date picker too. Date picker placed in Personal details - collapsible item. Someone please help me to fix collapsible and date picker.
Check: Placements App
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Placements MGIT</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min.js"></script>
<!-- If CDN not available, loading JQuery from Server-->
<script>
if (!window.jQuery) {
document.write('<script src="/js/jquery.min.js"><\/script>');
}
</script>
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="/css/materialize.min.css">
<!-- Compiled and minified JavaScript -->
<script src="/js/materialize.min.js"></script>
</head>
<body>
<nav>
<div class="nav-wrapper">
MGIT Placements
<i class="material-icons">M</i>
<ul class="left hide-on-med-and-down">
<li class="active">Login</li>
<li>Register</li>
<li>Upcoming</li>
<li>Contact</li>
</ul>
<ul class="side-nav" id="mobile-demo">
<li class="active">Home</li>
<li>Login</li>
<li>Register</li>
<li>Upcoming</li>
<li>Contact</li>
</ul>
</div>
</nav>
<div class="row">
<div class="student-profile">
<div class="col l8 offset-l2 m10 offset-m1">
<ul class="collapsible" popout" data-collapsible="accordion">
<li>
<div class="collapsible-header">Pefrsonal Info</div>
<div class="collapsible-body">
<div id="personal">
<div class="card black-text">
<div class="input-field col s12 m4 l4">
<input type="text" id="firstname" />
<label for="firstname">First Name:</label>
</div>
<div class="input-field col s12 l4 m4">
<input type="text" id="lastname" />
<label for="lastname">Last Name:</label>
</div>
<div class="input-field col s12 l4 m4">
<input type="text" id="surname" />
<label for="surname">Surname:</label>
</div>
<div class="input-field col s12 m6 l6">
<input type="text" id="father" />
<label for="father">Father Name:</label>
</div>
<div class="input-field col s12 l6 m6">
<input type="text" id="mother" />
<label for="mother">Mother Name:</label>
</div>
<div class="input-field col s12 m6 l6">
<input type="date" class="datepicker" />
</div>
</div>
</div>
</div>
</li>
<li>
<div class="collapsible-header">Academics Info</div>
<div class="collapsible-body"> Acaademics Should be here</div>
</li>
<li>
<div class="collapsible-header">Change Password</div>
<div class="collapsible-body">Password Change Shoule be here</div>
</li>
<li>
<div class="collapsible-header">View Data </div>
<div class="collapsible-body" id="dynamicdata">View Data</div>
</li>
</ul>
</div>
</div>
</div>
<style type="text/css">
<style type="text/css">
body {
background-color: #FCFCFC;
}
nav{
background-color: #33597C;
}
.updates{
position: absolute;
padding: 20px;
background: transparent;
}
marquee{
padding: 20px;
}
.vline{
width: 1px;
position: absolute;
background-color: orange;
}
.vline.medium{
top: initial;
height: 420px;
}
.small-login{
padding: 20px;
}
.login-fields{
padding: 20px;
}
h6{
color: #33597C;
}
h2 {
color: grey;
}
/* #4A6787 ; #33597C; */
.login-bg {
margin-top: 5%;
}
#message {
color: red;
margin: 20px;
}
#lgn_btn{
top: 20px;
background-color: #33597C;
width: 60%;
}
/* label focus color */
.input-field input[type=text]:focus + label {
color: #1A237E;
}
/* label underline focus color */
.input-field input[type=text]:focus {
border-bottom: 1px solid #1A237E;
box-shadow: 0 1px 0 0 #1A237E;
}
/* label focus color */
.input-field input[type=password]:focus + label {
color: #1A237E;
}
/* label underline focus color */
.input-field input[type=password]:focus {
border-bottom: 1px solid #1A237E;
box-shadow: 0 1px 0 0 #1A237E;
}
</style>
<script type="text/javascript">
jresp = '{% autoescape off%}{{jresp}}{% endautoescape%}';
resp = JSON.parse(jresp);
rollno = resp['rollno'];
details = resp['data'];
var update = document.getElementById('dynamicdata')
for (keys in details) {
update.innerHTML += "<b>"+keys[0].toUpperCase()+keys.slice(1).toLocaleLowerCase()+": </b>"+details[keys]+"<br />"
}
$('.datepicker').pickadate({
selectMonths: true,
selectYears: 15,
});
$(".button-collapse").sideNav();
$(document).ready(function () {
$('.collapsible').collapsible({
accordion: false // A setting that changes the collapsible behavior to expandable instead of the default accordion style
});
});
</script>
</body>
</html>
Well, after reading code, debugging and Googling I am able to fix the problem.
First thing - Materialize Collapsible.
Clicking on collapsible header, display property of collapsible body
is not changing.
So, adding display property for the element collapsible body, will fix the problem.
collapsible-body{
display: block;
}
`
Second thing - Materialize DatePicker
On Chrome, it is not responding to mouse clicks. But, responding to space button.
So, to fix this issue, I just added a bit of JQuery code as shown below.
Date Picker HTML Code
<div class="input-field col s12 m6 l6">
<label for="dob">Date of Birth:</label>
<input id="dob" type="text" class="datepicker" />
</div>
and mouse click event that triggers...
$('.datepicker').pickadate({
selectMonths: true,
selectYears: 40,
min: new Date(1990,0,1),
max: new Date(2000,11,31),
closeOnSelect: true,
});
$("#dob").click(function (event) {
event.stopPropagation();
$(".datepicker").first().pickadate("picker").open();
});
Here, you can see the working materialize date picker...
$('.datepicker').pickadate({
selectMonths: true,
selectYears: 40,
min: new Date(1990, 0, 1),
max: new Date(2000, 11, 31),
closeOnSelect: true,
});
$("#dob").click(function(event) {
event.stopPropagation();
$(".datepicker").first().pickadate("picker").open();
});
<head>
<!--Import jQuery before materialize.js-->
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/css/materialize.min.css">
<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/js/materialize.min.js"></script>
</head>
<body>
<div class="input-field">
<label for="dob">Date of Birth:</label>
<input id="dob" type="date" class="datepicker" />
</div>
</body>

How to combine inline and horizontal form in bootstrap?

Anyone who can explain how this would be done in bootstrap?
First try was with 2 inline forms, but then the search button screws it up...
So i was thinking on a combination of an inline and a horizontal form.
Any ideas how to do this?
My guess here is that you want to do this with as much bootstrap markup as possible and as little custom styling as possible, and in that case I would do it like so:
HTML:
<div class="panel panel-default">
<div class="panel-body">
<form class="form-horizontal">
<div class="row">
<div class="col-sm-10">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label for="search" class="col-sm-2 control-label">Find</label>
<div class="col-sm-10">
<input type="search" class="form-control" placeholder="What are you searching for?"/>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label for="email" class="col-sm-2 control-label">in</label>
<div class="col-sm-10">
<input type="number" class="form-control" placeholder="Postcode"/>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label for="email" class="col-sm-2 control-label">under</label>
<div class="col-sm-10">
<select class="form-control">
<option>All categories</option>
<option>Category 1</option>
<option>Category 2</option>
<option>Category 3</option>
<option>Category 4</option>
<option>Category 5</option>
</select>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label for="email" class="col-sm-2 control-label"></label>
<div class="col-sm-10">
<select class="form-control">
<option>Within 20 miles of</option>
<option>Within 30 miles of</option>
<option>Within 40 miles of</option>
<option>Within 50 miles of</option>
</select>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-2 cover-col">
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-sm btn-primary"><i class="glyphicon glyphicon-search"></i> Search</button>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
CSS:
.panel-default {
background-color: #e6ed9f;
}
.cover-col {
height: 6em;
}
.cover-col .btn {
display: block;
width: 100%;
height: 100%;
padding-left: 15px;
padding-right: 15px;
}
.cover-col .form-group {
height: 100%;
margin-bottom: 0;
}
.cover-col .form-group > div {
height: 100%;
}
JSFIDDLE