Thursday, December 22, 2016

destructuring in js


arrays

[x,...y] = [1,2,3,4,5,6]
[1, 2, 3, 4, 5, 6]
x
1
y
[2, 3, 4, 5, 6]

 objects

var x2 = {name:"herby",amount:23423,happy:true,getStatus:function(){return this.name + (this.happy?" is happy":" isnt happy" )  }}
/with renaming variable
var {name:newname, getStatus:getit} = x2;
console.log(newname); //herby

console.log(getStatus); // function etc

Calculated Column logic

lets say you have a date column date1
you can have logic as follows

if(columna = "hello",Today(),"")

this should really fail because "" is not a date
it doesn't fail, but access for example will come up with #error

 lets say I want to keep the null



if(columna = "hello",Today(),date1)

this fails because of circular logic

if(columna = "hello",Today(),null)
if(columna = "hello",Today(),blank)

these are also not correct syntax

if(columna = "hello",Today())

that works but updates the column with a 0 which SharePoint shows incredibly as a 0


calculated columns in sharepoint

calculated columns (misnomer? they are real columns) update upon insert and update of the row. now , if you update the formula, sharepoint will show the new result but the underlying data will still be based on the old formula (you can see this in access linked table for example). he data will only really change when you do an update on the row

Wednesday, December 21, 2016

template literals

for template literals use the back tick "`"

console.log(`this is the sum of 8 X 45 :${8 * 45}`)
var x = {name:"herbert"}
console.log(`this is his name:${x.name }`)

select all on multi line textbox

     private void hody_KeyDown(object sender, KeyEventArgs e)
        {
          
             TextBox txtBox = sender as TextBox;
             if (txtBox != null && txtBox.Multiline == true && e.Control == true && e.KeyCode == Keys.A)
                 txtBox.SelectAll();

        }

ctrl-c on treeview

   private void TV_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == (Keys.Control | Keys.C))
            {
                if (TV.SelectedNode != null)
                {
                    Clipboard.SetText(TV.SelectedNode.Text);
                }
                e.SuppressKeyPress = true;
            }


        }