473,516 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

In memory row selection

Rob
I want to implement a in-memory row selection function. Specifically,
given a table

Name Zip Phone
Tony 98034 127xxxxx
Mike 10023 271xxxx
Jame 10023 253xxxx

and a text box, I want the table automatically show relevant rows and
hide others. Say I type 10023,
only row 2&3 should be shown. Any existing package for doing this?

Oct 18 '07 #1
4 1292
On 18 Oct, 18:35, Rob <AJAX...@gmail.comwrote:
I want to implement a in-memory row selection function. Specifically,
given a table

Name Zip Phone
Tony 98034 127xxxxx
Mike 10023 271xxxx
Jame 10023 253xxxx

and a text box, I want the table automatically show relevant rows and
hide others. Say I type 10023,
only row 2&3 should be shown. Any existing package for doing this?
XML & XSLT might help you...
If not and you insist on doing it in Javascript I doubt that you will
find any existing package - it is too trivial to package it.

Oct 19 '07 #2
Thomas 'PointedEars' Lahn wrote:
It does not make sense in ECMAScript implementations to declare variables at
a different position in the source code than where they are first used if
declaration and first access are within the same execution context. That
only makes maintaining that code a lot harder.
What would you counsel in the following situation then ?

var i = 'abc';
// we want i to have value 'abc' here
function myScope() {
var i;
for (i=0;i<myArray.length();++i){}
// We want i to have the array's length here
}
myScope();
// we want i to have value 'abc' here
`Arial' is a font only Microsoft Windows provides by default. The
`font-family' property value can be a comma-separated list, where
the last item should specify a generic font family (here: sans-serif).
I think you're confusing Arial with Verdana.

--
Bart

Oct 24 '07 #3
On Oct 25, 11:35 am, RobG <rg...@iinet.net.auwrote:
On Oct 25, 5:54 am, Bart Van der Donck <b...@nijlen.comwrote:
Thomas 'PointedEars' Lahn wrote:
It does not make sense in ECMAScript implementations to declare variables at
a different position in the source code than where they are first used if
declaration and first access are within the same execution context. That
only makes maintaining that code a lot harder.

At the the top of the scope that the function is within
That should read "...the scope that the variable is within"
--
Rob
Oct 25 '07 #4
Thomas 'PointedEars' Lahn wrote:
RobG wrote:
>On Oct 25, 7:59 pm, Thomas 'PointedEars' Lahn wrote:
>>There is exactly no need to rip declaration and initialization
apart, and so to make maintenance of the code a lot harder,
in ECMAScript implementations.

That may be your point of view, opinions differ.

That there is no need to rip declaration and initialization
apart is not open for debate;
That is a very loaded expression. It is debatable whether declaration
and initialisation were ever together in the first place, and so whether
separating them would be 'ripping' them apart. Of course if they were
never together to start with any absence of a need to separate them is
not open for debate, it is just irrelevent.
it is a fact,
The absence of need may be a fact. As may be that absence not being open
for debate. But if declaration and initialisation were never really
together to start with then those facts are just the trivial
consequences of the act of separation being superfluous.
supported by the language specification and
its implementations.
The specification states that variable declarations are acted upon
during variable initialisation, prior to any code in the execution
context being executed, and that assignments (and so what is being
spoken of as initialisation here) are handled when the assignment
expression is evaluated during the execution of the code for the
execution context. This makes the two actions chronologically distinct,
with all of the first (declarations) being handled before any of the
latter (initialisations).
That this makes maintenance a lot harder is also not merely
an opinion.
No, that is a matter of opinion. Doing nothing other than separating
declarations form initialisations may make maintenance harder but in
realty the alternative is to formally declare all local variables at the
start of the containing function's body. This has the advantage that if
you want to verify that a variable used has been declared, or to insure
that it only has one declaration (because javascript could act on each
and every declaration for the same variable, which would make
re-declaring wasteful), then you only have to go to one location to
look. Reducing the time to find a declaration is a plus for maintenance.
Common sense already tells you that you would have to watch for
that all identifiers of variables that you use are declared a
number of lines before they are actually used; depending on the
complexity of the code, that may be a dozen, maybe a hundred lines.
Precisely, so if all declarations are in the same place it does not take
much time or effort to locate that one place to wee whatever you need to
know.
This supports declarations for unused
variables to stay in the code regardless.
Yes it does, but it trades that off against accidentally re-declaring
variables and the time needed to verify that a variable has been
declared locally and so is not (accidentally or intentionally) a global
variable, or one form a containing scope.

In reality all three problems can be solved with something like JSlint,
which will inform you of declared and unused variables, re-declared
variables and references to undeclared global variables.
It is also easy then to forget that the declaration
is recommended, and end up with a property assignment
instead.
<snip>

A question that may be well illustrated with this method from dojo
(which has a line highlighted by me:-

dojo.toJson = function( _indentStr){
_indentStr = _indentStr || "";
var nextIndent = (prettyPrint ? _indentStr +
dojo.toJsonIndentStr : "");
var newLine = (prettyPrint ? "\n" : "");
var objtype = typeof(it);
if(objtype == "undefined"){
return "undefined";
}else if((objtype == "number")||(objtype == "boolean")){
return it + "";
}else if(it === null){
return "null";
}
if(objtype == "string"){ return dojo._escapeString(it); }
var recurse = arguments.callee;
var newObj;
if(typeof it.__json__ == "function"){
newObj = it.__json__();
if(it !== newObj){
return recurse(newObj, prettyPrint, nextIndent);
}
}
if(typeof it.json == "function"){
newObj = it.json();
if(it !== newObj){
return recurse(newObj, prettyPrint, nextIndent);
}
}
if(dojo.isArray(it)){
var res = [];
for(var i = 0; i < it.length; i++){
var val = recurse(it[i], prettyPrint, nextIndent);
if(typeof(val) != "string"){
val = "undefined";
}
res.push(newLine + nextIndent + val);
}
return "[" + res.join(", ") + newLine + _indentStr + "]";
}
if(objtype == "function"){
return null;
}
var output = [];
for(var key in it){
var keyStr;
if(typeof(key) == "number"){
keyStr = '"' + key + '"';
}else if(typeof(key) == "string"){
keyStr = dojo._escapeString(key);
}else{
continue;
}
val = recurse(it[key], prettyPrint, nextIndent);
////////^^^
if(typeof(val) != "string"){
continue;
}
output.push(newLine + nextIndent + keyStr + ": " + val);
}
return "{" + output.join(", ") + newLine + _indentStr + "}";
}

The highlighted line is an assignment to an Identifier named - val -,
and I was wondering whether it was global or local so I went looking for
its declaration. If I had written the code its declaration would have
been at the top of the function body and I would have found it in a
couple of seconds (if that), but instead its declaration is one level of
indentation deeper than this assignment and it is in a branch of the
code that execution would not enter in the context of my interest in the
function's contents (the dojo.isArray function would have returned
false). The time wasted in shaving to scan every line of such a long
function for a variable declaration is not a contribution to easy
maintenance.

It is a commonly recommended 'best practice' that all variable
declarations and inner function declarations should be made at the start
of a function body. And it is a best practice that I agree with, because
it means you always know where to look for the declarations, the code
structure mirrors the handling of the declarations (that they are acted
upon before any other code is executed), and also the result does not
act to give the false impression, or re-enforce the false impression,
that javascript is block-scoped.

Richard.

Oct 27 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1341
by: MSNEWS | last post by:
I'm having problems using the word.applicationclass to load a word document. I've created this very simple code and I get the error below on the WordApp.Documents.Open("C:\temp\worddocs\1.doc", 0, 1) line. An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in test.exe Additional information: There is...
12
1870
by: James Brown | last post by:
Hi all, Having problems designing a template-class. I'll describe my scenario first then show what I've come up with so far: Need a class to provide pointer/array-like access to an area of physical memory located on a piece of custom hardware - this memory is only accessible using machine specific i/o so I want to hide all this in a...
2
1287
by: James Brown | last post by:
Hi again, I'm referring back to my previous posting of the same title, with everyone's help I've now got a better understanding of what my goals are and I have a class which now looks like: template <typename type> class PhysMem { public:
5
1023
by: Franck | last post by:
Hi, I'm addin javascript on some of my datagrid cells in the ItemCreatedEven which changes cell color on click (simulating selection). However, Postback event erase all selection and bring back default grid color. How can I keep in memory the user selection ?
2
3216
by: kayrogage | last post by:
I have an XML document that I am looping through to generate a word document. I loop through each element in the xml document and type it out in the word document, as I type out each element of text I apply the relevant style to it like so: With m_objselection .Style = strFormat .TypeText(strText) End With
2
1914
by: Asfar | last post by:
Hi, I have a VS2005 windows program written in c#. In this program I have an array list which stores many DataTable's. When I first run the pogram the arraylist is loaded with datatables. At this point when the see the memory used by the program in task manager it is 135,654K. Now when I minimize the application the memory goes down to...
4
2026
by: voidtwerp | last post by:
Hi, I hope this is not too OT but I would like clarification on how classes are held in memory. each object obviously has an individual copy of its data. I guess a class would only have one copy of its functions held in memory (not sure what part of memory this would be refered to as). Then whenever an object has a function called on it...
0
2409
by: Hypnotik | last post by:
My program is to simulate cache memory. I read in the info from 2 external files, 1) access 2) data in memory. When I read the information in I display the info...and it is all correct. However when I attempt to display the info in main anywhere the info is incorrect. I thought it might be a problem while I was reading the data in, but it...
0
3013
by: vjayis | last post by:
Hi i got an error while my site gets loaded Warning: mysql_query() : Unable to save result set in /path../includes/mysql.class.php on line 39 Error in Selection MySQL client ran out of memory My site didnt get loaded and was stuck by displaying this error ., so plz anyone one give me a solution.,
0
7276
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7581
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7548
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4773
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3267
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3259
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.