Sunday, 2 February 2014

Open Realism - The Philosophy of Bernard D'Espagnat




          Philosophy is the mother of all sciences, it is the root of all modes of thought. Science and Religion are branches of Philosophy, that's why we have Philosophy of Science and Philosophy of Religion. If science studies empirical reality and religion studies the numinous, philosophy is concerned with the study of operation and principles of science and religion itself.

Philosophy is the boss, it decides how a science has to operate, what principles it has to follow and what claims it can make about reality and to what extent. I always criticized physicists for their "Shut up and Calculate" attitude without arriving at a stand on the philosophical implications of quantum physics. Of course physics should only be concerned with measurements and calculations but physicists should go on to become philosophers of science and not become like Stephen Hawking who says 'Philosophy is dead'.

I am happy that one man has turned up to bring humility into science and has outlined the philosophical implications of quantum physics in his book On Physics and philosophy. Any sort of appreciation to Bernard D'Espagnat would be very less because he has independently arrived at his philosophy of open realism based on his life long study of quantum physics, even though he is aware of the similarities between his philosophy and the great eastern philosophical systems he has arrived at open realism based on his knowledge of quantum physics.

On Physics and Philosophy - Chapter 1

Scientists should abandon objectivist language at all cost while describing their theories in textbooks and in all modes of their expression and students of science need to be taught that science is only predictive and it doesn't give an ontological objective description of the reality which exists independent of us.

Now this philosophy of open realism should not be treated as just a personal opinion or just a philosophical ramblings of an old physicist instead this should be treated as an empirical fact because it is based on facts established from experiments. No wonder why he truly deserves the Templeton prize.

Statement by Professor Bernard d’Espagnat At The Templeton Prize News Conference

Speech for the diner in Honor of Bernard d’Espagnat

I was always a realist, I am not a proponent of Idealism and it feels so good to see a physicist arguing the same thing and I always argued that Kant was wrong when he said that it is impossible to know the noumenon and even Bernard agrees with it, he thinks that the Real being can be known.

One thing is a fact that is proved from experiments, the properties of a system do not preexist prior to measurements, an empirical fact proved by the quantum information science team. This begs the question which Einstein always asked, "Does the moon exist when we are not looking at it?".

Quantum physics has proved that Einsteinian realism is not feasible, the empirical reality is just isn't the way Einstein thought and actually what QM is saying is that "What we call empirical reality is only a state of mind" - Bernard D'Espagnat.

This further begs the question if reality is only a state of mind then what is mind? This is where the role of western and eastern Esotericism will come into the picture because they already know what mind is, things which you'd have never known if you stick yourself to a scientific attitude. Science isn't everything.

10) I said to Him, Lord, how does he who sees the vision see it, through the soul or through the spirit? 
11) The Savior answered and said, He does not see through the soul nor through the spirit, but the mind that is between the two that is what sees the vision and it is [...] 
(pages 11 - 14 are missing from the manuscript)
          - The Gospel  According to Mary Magdalene

Damn pages 11 - 14 are missing.... But no problem the west might have suppressed this knowledge but we have preserved them.


Sunday, 26 January 2014

Google Authorship and Google+ sucks

I am a very reserved person and I wish to remain as anonymous as possible on the world wide web but unfortunately it was very disturbing to see my posts in search engines being assigned to a different person holding an identical name as mine (the person had a Google+ profile and his image appeared beside my blog posts which is very annoying to say the least). For this reason I was forced to create a Google plus profile just for the sake of obtaining Google Authorship for my blogger posts. Now it turns out that there is a big flaw in Google plus itself, any stranger can add you into their circles and you can do nothing about it.

People are not going to like this Google, I definitely doesn't like to be associated with any strangers and I can't even do anything about it. For now I'll close my Google+ profile and switch back to my Blogger profile. I hope Google fixes these issues soon.

Can I remove myself from someone's circles?

Sunday, 5 January 2014

The joy of Gospel of Truth, Gospel of Philip and the Ishavasya Upanishad.

If there is any religious scripture which gives me strength and brings me joy then it must be these three important texts, Gospel of Truth, Gospel of Philip and the Ishavasya Upanishad. I know nothing of Hinduism and Christianity apart from these three works and I don't have to seek further because I am at rest now.

"The Father opens his bosom, but his bosom is the Holy Spirit. He reveals his hidden self which is his son, so that through the compassion of the Father the Aeons may know him, end their wearying search for the Father and rest themselves in him, knowing that this is rest." 
- Gospel of Truth

None of the Gospels in my opinion ever explained clearly as to who Christ was other than the Gospel of Truth.

"He is the shepherd who left behind the ninety-nine sheep which had not strayed and went in search of that one which was lost. He rejoiced when he had found it." 
- Gospel of Truth

Not only it is the Gospel which revealed who Christ was, it is also the only Gospel which explains about the origin of sin and ignorance.

"This ignorance of the Father brought about terror and fear. And terror became dense like a fog, that no one was able to see. Because of this, error became strong. But it worked on its hylic substance vainly, because it did not know the truth. It was in a fashioned form while it was preparing, in power and in beauty, the equivalent of truth. This then, was not a humiliation for him, that illimitable, inconceivable one. For they were as nothing, this terror and this forgetfulness and this figure of falsehood, whereas this established truth is unchanging, unperturbed and completely beautiful. 
For this reason, do not take error too seriously." 
- Gospel of Truth

The root cause of all sin in humanity is this, ignorance of the Father, ignorant of where we came from and where we are going. Gospel of Truth is the only Gospel or the only work in the western literature where it's author has got the ontology of God absolutely right, which cannot be found in any one of the works of western theologians like Cicero or Thomas Aquinas, none of the western theologians or philosophers have got the ontology of God right apart from the author of Gospel of Truth.

The author of Gospel of truth was neither a theologian,nor a metaphysician or a philosopher, for if he was any one of them, even he, like others would fail to know the ontology of God but he was a pneumatic who had faith in the pneumatic Christ and hence he received the grace of the Father and was brought into the place of rest.

"Such is the place of the blessed; this is their place. As for the rest, then, may they know, in their place, that it does not suit me, after having been in the place of rest to say anything more. But he is the one in whom I shall be in order to devote myself, at all times, to the Father of the All and the true brothers, those upon whom the love of the Father is lavished, and in whose midst nothing of him is lacking. It is they who manifest themselves truly since they are in that true and eternal life and speak of the perfect light filled with the seed of the Father, and which is in his heart and in the Pleroma, while his Spirit rejoices in it and glorifies him in whom it was, because the Father is good. And his children are perfect and worthy of his name, because he is the Father. Children of this kind are those whom he loves."
          - Gospel of Truth

 The verse which reveals the ontology of God in Gospel of Truth is this-

"It was a great wonder that Aeons were in the Father without being acquainted with him and that they alone were able to emanate in as much as they were not able to perceive and recognize the one in whom they were." 
- Gospel of Truth
All the Aeons are Pleromas by themselves and all of them reside in the Father and form his body. For this important reason the Vedic Aryans divided the vedic worship into two forms called the Vishrutha and the Samasthi forms. In the Vishrutha form of Vedic worship they worshipped the each individual Aeon who had emanated from the Father and glorified each of the Aeons describing their nature and appearance i.e. their ontology in the form of mantras and in the Samasthi form of Vedic worship they worshipped the one Father, (Savithru, Sun God) as a whole containing all the Aeons with in him.

This is the reason why I love the Gospel of Truth so much, because no where the ontology of God is so well explicitly expressed other than here.

The author of the book - "The Spiritual Seed - The Church of the Valentinians", Einar Thomassen said,
"not every time he (Valentinus) sat down to write a gospel (Gospel of Truth) where he was going to throw in all the cosmology and cosmogony and theogony."

Next we move on to an another remarkable work which is the Ishavasya Upanishad.

The author of this Upanishad is the great sage, Yagnavalkya. Many westerners quote the dialogue between Yagnavalkya and Maitreyi and defend the philosophy of Advaita which is quite good but very few people know as to how this Upanishad came about. That's a big story though and if you are interested you can read the full biography of Yagnavalkya here or a shorter version of it from wiki.

"Then Yājñavalkya determined not to have any human guru thereafter. Thus he began to propitiate the Sun God, Surya. Yājñavalkya worshipped and extolled the Sun, the master of the Vedas, for the purpose of acquiring the fresh Vedic portions not known to his preceptor, Vaiśampāyana.[5] 
The Sun God, pleased with Yājñavalkya penance, assumed the form of a horse and graced the sage with such fresh portions of the Yajurveda as were not known to any other. This portion of the Yajurveda goes by the name of Śukla Yajurveda or White-Yajurveda on account of it being revealed by Sun. It is also known as Vajasaneya Yajurveda, because it was evolved in great rapidity by Sun who was in the form of a horse through his manes.The rhythm of recital of these vedas is therefore to the rhythm of the horse canter and distinguishes itself from the other forms of veda recitals. In Sanskrit, term "Vaji" means horse."
As it is clearly stated Yajnavalkya extolled the Sun God, the master of the Vedas and the Sun god, through Yajnavalkya gave the ShuklayajurVeda and the Ishavasya Upanishad to the world. How foolish or moronish it is to say that the philosophy of Advaita is the death of Gods, no my dear westerners it is actually the return of the Gods. Gnostic Christianity, Advaita, Taoism and Tibetan Buddhism makes absolutely no sense without the Aeons or Gods. I am least concerned about making my views rational or scientific, that is not important for me, what is important for me is to ensure that these sensitive traditions do not get misrepresented in the hands of western metaphysicians, scholars and philosophers. It is nothing but scholarly prejudice.

The scientific method is not the correct way to study these traditions, I think all scholars or philosophers in this field must adopt "sympathetic empiricism", a term coined by Arthur Versluis, as the main methodology to study these traditions because this is not religion or science, this is Esotericism and in Esotericism there will be always those who study these traditions purely from an academic viewpoint and those who study these traditions from a traditional viewpoint and in order to experience an elitist phenomena such as Esotericism it is important for the scholars or the researchers to participate to some extent in the traditions which they study.

“While I am convinced of the critical importance of historiography in the study of esotericism (and for this reason all of my academic books are firmly grounded in historical method) I do not believe that historiography is adequate in itself to convey the complex, multivalent nature of esoteric thought, traditions, or most of all, experience. Esotericism, given all its varied forms and its inherently multidimensional nature, cannot be conveyed without going beyond purely historical information: at minimum, the study of esotericism, and in particular mysticism, requires some degree of imaginative participation in what one is studying.” 
          - Arthur Versluis

We are least concerned about the historical Buddha or the historical Jesus, we don't care when Jesus was born, whether he was born on 25th of December or some other day it is of least interests to us, what happened to him between the years 12 to 30, again we don't care. Some say, "Paul never met Jesus and hence his teachings are not authoritative." Yes he never met Jesus, so what?  Saint Paul directly received the Pleromic revelation from the pneumatic Christ, this is what is important to us. 'The Christ in you'.

Most westerners think that it was Shankara of the 8th century who established the Advaita philosophy which is wrong, the philosophy of Advaita was already fully established by the Vedic Seers, what Shankara did in the 8th century was he took us out from the repeated onslaught of Buddhist influence and  re-established the philosophy of Advaita by writing commentaries on Brahma Sutras and by travelling through out India. It is for this reason he dis-agreed with his teacher Gaudapada (on minute points) who was highly influenced by Buddhism and Shankara went his own way and re-established the philosophy of Advaita.

But the influence of Buddhist ideas was too strong even for someone like Shankara and for this reason though knowingly or unknowingly he did not fully expressed or captured the full meaning of the Ishavasya Upanishad. This criticism against Shankara can be found in the voluminous works of the mystic Aurobindo.

"The main obstacle that stands in the way of accepting the straight forward meaning of the Isha Upanishad and rightly understanding its inner truth about the Brahman, the Self and the Divine, is Mayavada, Illusionism, preached by Shankaracharya and the commentary he wrote on this Upanishad. The one-pointed drive towards withdrawal that is Illusionism and the much-praised inaction of the Sannyasi are completely at variance with the Isha Upanishad. If the meaning of the slokas is strained and tortured to give an opposite sense, the solution of this quarrel becomes impossible. The Upanishad in which it is written: “Doing verily works in this world one should wish to live a hundred years”, and again: “Action cleaves not to a man” — the Upanishad which proclaims with courage: “Into a blind darkness they enter who follow after the Ignorance, they as if into a greater darkness who devote themselves to the Knowledge alone”; and again says: “By the Birth one enjoys Immortality”, how can that Upanishad be reconciled with Mayavada, Illusionism and the path of withdrawal? A highly erudite person, who was possibly the chief sponsor of Monism in South India after Shankara, expunged it from the list of the twelve Upanishads and installed the Nrisimhatapini in its place. Shankaracharya was not so daring as to alter the prevailing canon. The Upanishad was a “Sruti” (heard scripture), and Illusionism was a subject for inquiry in the “Sruti” and as such, he assumed, the meaning of the “Sruti” could not but be favourable to real Illusionism." 

- Aurobindo, Ishavasya Upanishad


"The Isha Upanishad introduces to us the integral spiritual realisation and the principle of the integral yoga; within a short space it resolves many difficult problems. It is a śruti replete with sublime, profound and fathomless significances. This Upanishad, concluded in eighteen slokas, explains in these small mantras many major truths of the world. Such “infinite riches in a little room” can be found only in this śruti."
       - Aurobindo

Aurobindo has written a full commentary on the Ishavasya Upanishad, interested readers can do a simple google search and find his works.


This is an very important verse for me, this is the 15th verse of the Isha Upanishad, it is a very short Upanishad with just 18 verses in it. Here Pushan means the Sun God and the golden disc is his divine light rays emanating from his anthropomorphic body, as I said already all the Aeons reside in him and form his body, in that each individual light ray is an Aeon, so when I say all the Aeons reside in the Father it doesn't mean they reside with him holding an anthropomorphic form instead they reside in the Father as a form of light rays and when these Aeons are studied individually they appear as anthropormorphic forms. The seer having seen the Father pleads him to reduce the intensity of the light rays which is emanating from his body so that he can clearly see him and become one with him so that he can know the truth and lead a righteous life.

One cannot lead a righteous life without knowing the Father, how can one lead a life of righteousness if truth is not rent in him.

"People cannot see anything in the real realm unless they become, if you have seen Christ, you have become Christ, if you have seen the spirit you have become the spirit, if you have seen the Father you will become the Father" 
- Gospel of Truth


Thursday, 26 December 2013

An Invitation for Inter-Faith dialogue - Sunya, Purna and Pleroma

I have not put my hands on this book so I cannot review what is inside the book.


But I can give you the implications if anyone wants to take this road.

Om 
Purnamadah PurnamidamPurnat PurnamudachyatePurnasya PurnamadayaPurnameva VashishyateOm shanti, shanti, shanti


- Isha Upanishad

Translation - 

All this is full. All that is full.
From fullness, fullness comes.
When fullness is taken from fullness,
Fullness still remains.
O M shanti shanti shanti
-------------------------------------------------------------------------------------------------

Col 2:9 "In Christ dwell's all the pleroma(fullness) of deity in bodily form"

THE SEVEN SERMONS TO THE DEAD
WRITTEN BY BASILIDES IN ALEXANDRIA,
THE CITY WHERE THE EAST
TOUCHETH THE WEST.

Sermo I

The dead came back from Jerusalem, where they found not what they sought. They prayed me let them in and besought my word, and thus I began my teaching.

Harken: I begin with nothingness. Nothingness is the same as fullness. In infinity full is no better than empty. Nothingness is both empty and full. As well might ye say anything else of nothingness, as for instance, white is it, or black, or again, it is not, or it is. A thing that is infinite and eternal hath no qualities, since it hath all qualities.

This nothingness or fullness we name the PLEROMA. Therein both thinking and being cease, since the eternal and infinite possess no qualities. In it no being is, for he then would be distinct from the pleroma, and would possess qualities which would distinguish him as something distinct from the pleroma.

In the pleroma there is nothing and everything. It is quite fruitless to think about the pleroma, for this would mean self-dissolution.

CREATURA is not in the pleroma, but in itself. The pleroma is both beginning and end of created beings. It pervadeth them, as the light of the sun everywhere pervadeth the air. Although the pleroma pervadeth altogether, yet hath created being no share thereof, just as a wholly transparent body becometh neither light nor dark through the light which pervadeth it. We are, however, the pleroma itself, for we are a part of the eternal and infinite. But we have no share thereof, as we are from the pleroma infinitely removed; not spiritually or temporally, but essentially, since we are distinguished from the pleroma in our essence as creatura, which is confined within time and space.
Yet because we are parts of the pleroma, the pleroma is also in us. Even in the smallest point is the pleroma endless, eternal, and entire, since small and great are qualities which are contained in it. It is that nothingness which is everywhere whole and continuous. Only figuratively, therefore, do I speak of created being as a part of the pleroma. Because, actually, the pleroma is nowhere divided, since it is nothingness. We are also the whole pleroma, because, figuratively, the pleroma is the smallest point (assumed only, not existing) in us and the boundless firmament about us. But wherefore, then, do we speak of the pleroma at all, since it is thus everything and nothing?
I speak of it to make a beginning somewhere, and also to free you from the delusion that somewhere, either without or within, there standeth something fixed, or in some way established, from the beginning. Every so-called fixed and certain thing is only relative. That alone is fixed and certain which is subject to change.

What is changeable, however, is creatura. Therefore is it the one thing which is fixed and certain; because it hath qualities: it is even quality itself.

The question ariseth: How did creatura originate? Created beings came to pass, not creatura; since created being is the very quality of the pleroma, as much as non-creation which is the eternal death. In all times and places is creation, in all times and places is death. The pleroma hath all, distinctiveness and non-distinctiveness.

Distinctiveness is creatura. It is distinct. Distinctiveness is its essence, and therefore it distinguisheth. Therefore man discriminateth because his nature is distinctiveness. Wherefore also he distinguisheth qualities of the pleroma which are not. He distinguisheth them out of his own nature. Therefore must he speak of qualities of the pleroma which are not.

What use, say ye, to speak of it? Saidst thou not thyself, there is no profit in thinking upon the pleroma?

That said I unto you, to free you from the delusion that we are able to think about the pleroma. When we distinguish qualities of the pleroma, we are speaking from the ground of our own distinctiveness and concerning our own distinctiveness. But we have said nothing concerning the pleroma. Concerning our own distinctiveness, however, it is needful to speak, whereby we may distinguish ourselves enough. Our very nature is distinctiveness. If we are not true to this nature we do not distinguish ourselves enough. Therefore must we make distinctions of qualities.

What is the harm, ye ask, in not distinguishing oneself? If we do not distinguish, we get beyond our own nature, away from creatura. We fall into indistinctiveness, which is the other quality of the pleroma. We fall into the pleroma itself and cease to be creatures. We are given over to dissolution in the nothingness. This is the death of the creature. Therefore we die in such measure as we do not distinguish. Hence the natural striving of the creature goeth towards distinctiveness, fighteth against primeval, perilous sameness. This is called the principium individuationis. This principle is the essence of the creature. From this you can see why indistinctiveness and non-distinction are a great danger for the creature.

We must, therefore, distinguish the qualities of the pleroma. The qualities are pairs of opposites, such as—
The Effective and the Ineffective.
Fullness and Emptiness.
Living and Dead.
Difference and Sameness.
Light and Darkness.
The Hot and the Cold.
Force and Matter.
Time and Space.
Good and Evil.
Beauty and Ugliness.
The One and the Many. etc.
The pairs of opposites are qualities of the pleroma which are not, because each balanceth each. As we are the pleroma itself, we also have all these qualities in us. Because the very ground of our nature is distinctiveness, therefore we have these qualities in the name and sign of distinctiveness, which meaneth—
1. These qualities are distinct and separate in us one from the other; therefore they are not balanced and void, but are effective. Thus are we the victims of the pairs of opposites. The pleroma is rent in us.
2. The qualities belong to the pleroma, and only in the name and sign of distinctiveness can and must we possess or live them. We must distinguish ourselves from qualities. In the pleroma they are balanced and void; in us not. Being distinguished from them delivereth us.
When we strive after the good or the beautiful, we thereby forget our own nature, which is distinctiveness, and we are delivered over to the qualities of the pleroma, which are pairs of opposites. We labor to attain to the good and the beautiful, yet at the same time we also lay hold of the evil and the ugly, since in the pleroma these are one with the good and the beautiful. When, however, we remain true to our own nature, which is distinctiveness, we distinguish ourselves from the good and the beautiful, and, therefore, at the same time, from the evil and the ugly. And thus we fall not into the pleroma, namely, into nothingness and dissolution.

Thou sayest, ye object, that difference and sameness are also qualities of the pleroma. How would it be, then, if we strive after difference? Are we, in so doing, not true to our own nature? And must we none the less be given over to sameness when we strive after difference?

Ye must not forget that the pleroma hath no qualities. We create them through thinking. If, therefore, ye strive after difference or sameness, or any qualities whatsoever, ye pursue thoughts which flow to you out of the pleroma; thoughts, namely, concerning non-existing qualities of the pleroma. Inasmuch as ye run after these thoughts, ye fall again into the pleroma, and reach difference and sameness at the same time. Not your thinking, but your being, is distinctiveness. Therefore not after difference, as ye think it, must ye strive; but after your own being. At bottom, therefore, there is only one striving, namely, the striving after your own being. If ye had this striving ye would not need to know anything about the pleroma and its qualities, and yet would ye come to your right goal by virtue of your own being. Since, however, thought estrangeth from being, that knowledge must I teach you wherewith ye may be able to hold your thought in leash.

- Carl C Jung.

-------------------------------------------------------------------------------------------------------------------
The Angulimaliya Sutra consists largely of teachings by the bodhisattva Angulimala - in the immediate presence of the Buddha, under his direct spiritual influence and with his approval - on the correct understanding of Buddhist doctrine. The Sutra is most insistent that the tathagatagarbha and the self (Ātman) are real and that to deny their existence is to lapse into a state of dangerous spiritual imbalance. Thus, to seek out the tathagatagarbha - which is equated with the true Self - is deemed of great value. The Buddha teaches the bodhisattva Manjushri (traditionally, the bodhisattva given to the highest insight) that practising the spiritual life is meaningful only because there is a 'self principle' (the tathagatagarbha or 'atma-dhatu' - 'essence of Self') with which the quest can be rewarded. He states: 
Mañjuśrī, people churn milk because they understand that butter is present therein. Why do people not churn water ? Because that substance is not present there. Likewise, Mañjuśrī, people maintain moral discipline (śīla) and engage in the holy life (brahmacarya) because of the existence of the Tathāgata-garbha. 
Moreover, Mañjuśrī, people who want gold and are endowed with discernment, dig in cliffs. Why do they not dig in trees? They dig in rocks where gold-ore (suvarna-dhātu) is present, but they do not dig in trees, where there is no gold. Likewise, Mañjuśrī, people who discern the presence of the dhātu [i.e., buddha-dhatu, which means buddha principle] think to themselves, "I shall become a buddha" and so maintain the moral discipline and engage in the holy life. Furthermore, Mañjuśrī, if there were no dhātu, the holy life would be pointless. Just as butter will never be produced from water even if one were to churn it for a billion years, similarly there would be no benefit for those attached to a self who engage in the holy life and the moral discipline if there were no self principle [ātma-dhātu]. 
The sutra is remarkable for the vigour and passion with which Angulimala teaches Dharma and for its doctrine that at the heart of all beings is one unified principle: the buddha-dhatu (Buddha-nature) or tathagatagarbha. The doctrines of this sutra are also strikingly congruent with those of the much longer Mahaparinirvana Sutra. 
- Angulimaliya Sutra
For a fuller understanding of whether tathagatagarbha is ontologically real or empty continue reading here.
------------------------------------------------------------------------------------------------------------

As I have made out very clear in my other posts, for us Pleroma is not just an abstract idea, it has a physical local existence and forms the body of Christ in Christianity, body of Savitr in Hinduism and body of Samanthabhadra in Buddhism.


The 30 odd Aeons of Valentinianism.

The hundred peaceful and wrathful deities of Tibetan Buddhism.


List of Rigvedic deities by number of dedicated hymns, after Griffith (1888). Some dedications are to paired deities, such as Indra-Agni, Mitra-Varuna, Soma-Rudra, here counted doubly.

- Rig Vedic Deities

The implications are quite clear:

All denominations of Christianity, Buddhism and Hinduism will perish and die soon except Valentinianism in Christianity worshipping the pneumatic Christ (uniting all Christians having a fuller esoteric interpretation of the Bible), Sauram in Hinduism worshipping the Sun God (uniting all Hindus having a fuller esoteric interpretation of the Vedas and the Upanishads) and Dzogchen in Buddhism upholding the Buddha-nature or tathagathagarbha.

You better know the implications before getting yourself into such a venture! Now one can see why I have given so much importance to Valentinianism compared to Souram or Dzogchen. It is because it is only in Valentinianism that one finds explicit expressions of my views and in Souram and Dzogchen it exists implicitly and one has to do a lot of reading and research in these two religions to find similar expressions of thoughts as there is in Valentinianism.

Saturday, 14 December 2013

Live search filter for jquery handsontable

Search:



I normally don't blog much about my coding skills which is the job that I do daily but since I like Jquery very much I might start doing it more often. Here I have shared a simple live search filter for Handsontable. Just ensure that you declare myData globally in your javascript.

Update:
Since many have asked as to how to keep the changes made to the grid persistent during searching and pagination operations I have added three plugin hooks to model the changes made to the grid to the original data source. You need to hook onto these three events of handsontable.
afterChange - to model the changes when the user searches for a row and edits a cell.
beforeRemoveRow - when the user removes a particular row.
afterCreateRow - when the user inserts a new row at a particular index.
With this your grid is ready and you can post the data to the server to save it in your database. You can do the validations at the client-side or at the server-side.
<style>
.pagination {
        padding: 2px 0;
        margin: 2px;
    }
.pagination a {
            border: 1px solid grey;    
            padding: 2px 5px;
        } 
</style>

<script type="text/javascript">



$(document).ready(function (){

//have a unique row index or a unique running number in your original data source for preserving persistent changes made to the grid. 

var myData = [["Maria Anders", "Sales Representative", "Alfreds Futterkiste", "Germany", "00-800-531-82220", "R||0"],
["Ana Trujillo", "Owner", "Ana Trujillo Emparedados y helados", "Mexico", "00-100-531-7676", "R||1"],
["Antonio Moreno", "Owner", "Antonio Moreno Taquería", "Mexico", "00-200-541-820", "R||2"],
["Thomas Hardy", "Sales Representative", "Around the Horn", "UK", "00-80-591-5620", "R||3"],
["Christina Berglund", "Order Administrator", "Berglunds snabbköp", "Sweden", "00-80-232-86320", "R||4"],
["Hanna Moos", "Sales Representative", "Blauer See Delikatessen", "Germany", "00-300-521-89890", "R||5"],
["Frédérique Citeaux", "Marketing Manager", "Blondel père et fils", "France", "00-200-531-82520", "R||6"],
["Martín Sommer", "Owner", "Bólido Comidas preparadas", "Spain", "00-809-431-82320", "R||7"],
["Laurence Lebihan", "Owner", "Bon app'", "France", "00-800-531-82220", "R||8"],
["Elizabeth Lincoln", "Accounting Manager", "Bottom-Dollar Markets", "Canada", "00-400-561-89220", "R||9"],
["Victoria Ashworth", "Sales Representative", "B's Beverages", "UK", "00-800-531-82220", "R||10"],
["Patricio Simpson", "Sales Agent", "Cactus Comidas para llevar", "Argentina", "00-800-531-82229", "R||11"],
["Francisco Chang", "Marketing Manager", "Centro comercial Moctezuma", "Mexico", "00-800-531-82645", "R||12"],
["Yang Wang", "Owner", "Chop-suey Chinese", "Switzerland", "00-100-521-82456", "R||13"],
["Pedro Afonso", "Sales Associate", "Comércio Mineiro", "Brazil", "00-700-431-85620", "R||14"],
["Elizabeth Brown", "Sales Representative", "Consolidated Holdings", "UK", "00-600-231-82900", "R||15"],
["Sven Ottlieb", "Order Administrator", "Drachenblut Delikatessen", "Germany", "00-200-561-89220", "R||16"],
["Janine Labrune", "Owner", "Du monde entier", "France", "00-300-431-88720", "R||17"],
["Ann Devon", "Sales Agent", "Eastern Connection", "UK", "00-201-531-82850", "R||18"],
["Roland Mendel", "Sales Manager", "Ernst Handel", "Austria", "00-802-541-82820", "R||19"]];


var noOfRowstoShow = 4; //set the maximum number of rows that should be displayed per page.

$("#exampleGrid").handsontable({
    startRows: 5,
    startCols: 5,
    rowHeaders: true,
    colHeaders: true,
    columnSorting: true,
    colHeaders: ["Employee Name", "Designation", "Company Name", "Country", "Contact No"],
    contextMenu: ["row_below", "remove_row", "undo", "redo", "sep1", "sep2", "sep3"],
    columns: [{ data: 0, type: 'text' }, { data: 1, type: 'text' }, { data: 2, type: 'text' }, { data: 3, type: 'text' }, { data: 4, type: 'text'}],
    afterChange: function (change, source) {
        if (source === 'edit') {
            var datarow = $("#exampleGrid").handsontable('getDataAtRow', change[0][0]);
            for (row = 0, r_len = myData.length; row < r_len; row++) {
                for (col = 0, c_len = myData[row].length; col < c_len; col++) {
                    if (myData[row][col] == datarow[5]) {
                        myData[row][change[0][1]] = change[0][3];
                    }
                }
            }
        }
    },
    afterCreateRow: function (index, amount) {
        var rowvalue = myData[myData.length - 1][5];
        var rowno = rowvalue.split("||");
        var newrow = ["", "", "", "", "", "R||" + (parseInt(rowno[1]) + 1)];

        myData.splice(index, 0, newrow);
        getgridData(myData, "1", noOfRowstoShow);
    },
    beforeRemoveRow: function (index, amount) {
        var removerow = $("#exampleGrid").handsontable('getDataAtRow', index);
        var flag = false;
        for (row = 0, r_len = myData.length; row < r_len; row++) {
            for (col = 0, c_len = myData[row].length; col < c_len; col++) {
                if (myData[row][col] == removerow[5]) {

                    myData.splice(row, 1);
                    flag = true;
                }
                if (flag == true) {
                    break;
                }
            }
            if (flag == true) {
                break;
            }
        }

    }
});

loadData();

function loadData() {
    getgridData(myData, "1", noOfRowstoShow);
}

$('#searchgrid').on('keyup', function (event) {
    var value = ('' + this.value).toLowerCase(), row, col, r_len, c_len, td;
    var example = $('#exampleGrid');
    var data = myData;
    var searcharray = [];
    if (value) {
        for (row = 0, r_len = data.length; row < r_len; row++) {
            for (col = 0, c_len = data[row].length; col < c_len; col++) {
                if (data[row][col] == null) {
                    continue;
                }
                if (('' + data[row][col]).toLowerCase().indexOf(value) > -1) {
                    searcharray.push(data[row]);
                    break;
                }
                else {
                }
            }
        }
        getgridData(searcharray, "1", noOfRowstoShow);
    }
    else {
        getgridData(myData, "1", noOfRowstoShow);
    }
});

function getgridData(res, hash, noOfRowstoShow) {

    var page = parseInt(hash.replace('#', ''), 10) || 1, limit = noOfRowstoShow, row = (page - 1) * limit, count = page * limit, part = [];

    for (; row < count; row++) {
        if (res[row] != null) {
            part.push(res[row]);
        }
    }

    var pages = Math.ceil(res.length / noOfRowstoShow);
    $('#gridpage').empty();
    for (var i = 1; i <= pages; i++) {
        var element = $("<a href='#" + i + "'>" + i + "</a>");
        element.bind('click', function (e) {
            var hash = e.currentTarget.attributes[0].nodeValue;
            $('#exampleGrid').handsontable('loadData', getgridData(res, hash, noOfRowstoShow));
        });
        $('#gridpage').append(element);
    }
    $('#exampleGrid').handsontable('loadData', part);
    return part;
}
});
</script>

Search: <input id="searchgrid" type="text" />

<div id="exampleGrid">
</div>
<div id="gridpage" class="pagination">
  </div>