:: Forum >>

How do I delete (and insert) a Row with own Index

hi experts,

i am trying to delete (and insert) rows in my grid.
the hints found in this forum may work wonderful, if you use
indexing by default, but i use a database-field as index and
so method like slice or splice do not work as they are supposed..

i define my grid as follows:

GridData = {
"dbIdx1":["a","b,"c"],
"dbIdx2":["a","b,"c"],
"dbIdx3":["a","b,"c"]
}

any help is appreciated, thanks a lot in advance,
yves
Monday, November 1, 2004
since associative arrays do not support some methods a normal array does (e.g. length, splice and so on) this would be quite complicated hack...
so i switched to a normal griddata-array and everything´s fine now...
... or does anybody has a quick solution?

thanks anyway,
yves
yves
Monday, November 1, 2004
This is so simple.

There is an operator in Javascript called delete. All you need to do in order to delete a row from an associative array is to do something like this :

GridData = {
"dbIdx1":["a","b,"c"],
"dbIdx2":["a","b,"c"],
"dbIdx3":["a","b,"c"]
}

delete GridData[dbIdx2]; //This will remove the second row


My own example is:

<script language="JavaScript" type="text/JavaScript">
    var d = new Array();
    d['a'] = 'First Element';
    d['b'] = "BBb";
    d["c"] = "CCC";
    d['d'] = "DDD";
    document.write ("<br />d['a']="+d['a']+"<br />");

</script>
<br><input type="button" onClick="delete d['a']" value="Delete It"><!-- And the first element WAS -->
<input type="button" onClick="alert(d['a'])" value="Show It"><!-- The first element IS -->
WebMaestro
Monday, February 21, 2005
Oops, I forgot the quotation marks

GridData = {
"dbIdx1":["a","b,"c"],
"dbIdx2":["a","b,"c"],
"dbIdx3":["a","b,"c"]
}

delete GridData['dbIdx2']; //This will remove the second row
WebMaestro
Monday, February 21, 2005

This topic is archived.


Back to support forum

Forum search