i was just going through this post. Well i want to dynamically add columns to my grid (the column names will come from a dropdown in my page,so i cannot hardcode the column names as it may change anytime ).Can i use yhis piece of code to add columns dynamically in my grid.
I'm relatively new to this level of complexity in JavaScript but I'm guessing that what you are doing is using Google Chrome's equivalent to Firebug and that you're finding a bug in the grid.import.js file.
Yes, this is a bug. If the goal is just remove first column from an array we need to use x=x.slice(1) method bkz x.splice(0) just truncate our arrays if we use browser different from IE.
So yes, it is a bug. The problem is that splice has two /required/ parameters. The first is the index of the point to insert/delete, and the second is the number of elements to delete. (Subsequent parameters are elements to be inserted after the deletes have taken place)
I'm guessing that most browsers treat the single parameter case as “delete 1”, but chrome treats it as “delete to end of array”.
Since omitting the second parameter is an error, either behavior is allowed.
So a simpler (and probably more efficient) fix would be to change it to splice(0,1);