Powerbuilder Drop down datawindow filter while user is typing? - powerbuilder

I need to know how to let the user filter while typing in a drop down datawindow in powerbuilder

In editchanged event of datawindow
Define field as datawindow child
DataWindowChild child1
Dw_1.getchild("sub_branch_id",child1) // sub_branch_id name of column
// which is dropdowndatawindow
// Displays name
If data = "" then
String fltr
Fltr = "sub_branch_name " +"like"+"'%" +data+"%'" // filter on name
End if


Inner joins using LLBLGen?

How could I do a simple join using LLBLGen?
table1 - clientTable (address, phone, etc)
table2 - employeeTable (name, etc)
table3 - clientEmployeeTable (clientid, employeeid)
I'm filling out a datagrid using the employeeId with fields for the client information (address, phone, etc) and I'm not sure how I could retrieve this using LLBLGen. I suppose I could create a stored procedure but maybe there's an easier way?
I'm completely new with LLBLGen.
I've been using stored procedures meanwhile but maybe there's a better way.
// in stored proc
SELECT (my specific fields)
FROM [client].[List] abl
INNER JOIN [client].ClientGroup cg ON cg.ClientGroupId = abl.ClientGroupId
// in code
DataTable dt=RetrievalProcedures.GetEmployeeNote(EmployeeId);
rgridNotes.DataSource = dt;
You probably want to create some 'fields on related fields'. You can add ClientGroup properties to the Client entity to access them transparently. This only works for directly related fields in an (m:1) relation. If you want to join deeper than that, you have to use typed lists.
When you fetch entities and you want to join because of the where statement, you can use relations to join the tables and build a predicate.
Welcome to LLBLGen! Great product once you're schooled up. One way to get information from a variety of joined tables is with a Typed List of your own design.
Your "my specific fields" get defined in the ResultsetFields. Your WHERE clause is defined with an IPredicateExpression. Your JOIN clauses are brilliantly handled by the IRelationCollection and the .Relations properties of each Entity.
When trying to get up to speed, running the SQL Server profiler (presuming you're using MSSQL) is key to see how your code changes in LLBLGen affect the actual SQL requested from the server. Managing all of the ()'s in the JOIN and WHERE clauses sometimes requires careful ordering but most of the time works on the first try. Here's a generic snippet that we use:
private static DataTable GetTheGoodsOnEmployeeClients()
// Define the fields that you want in your result DataTable
ResultsetFields fields = new ResultsetFields(2);
fields.DefineField(MyEntityFields.FieldName1, 0);
fields.DefineField(MyEntityFields.FieldName2, 1, "Field Name Alias");
// Add the WHERE clause to the query - "Condition" can be a literal or a variable passed into this method
IPredicateExpression filter = new PredicateExpression();
filter.Add(MyEntityFields.FieldName == "Condition");
// Add all JOIN clauses to the relation collection
IRelationCollection relations = new RelationCollection();
relations.Add(MyEntity.Relations.FKRelationship, JoinHint.Left);
ISortExpression sort = new SortExpression();
sort.Add(MyEntityFields.FieldName | SortOperator.Ascending);
// Create the DataTable, DAO and fill the DataTable with the above query definition/parameters
DataTable dt = new DataTable();
TypedListDAO dao = new TypedListDAO();
dao.GetMultiAsDataTable(fields, dt, 0, sort, filter, relations, false, null, null, 0, 0);
return dt;
Your specific need:
SELECT (my specific fields)
FROM [client].[List] abl
INNER JOIN [client].ClientGroup cg ON cg.ClientGroupId = abl.ClientGroupId
Would thus become:
private static DataTable GetTheGoodsOnEmployeeClients()
// Define the fields that you want in your result DataTable
ResultsetFields fields = new ResultsetFields(3);
fields.DefineField(ClientFields.ClientId, 0);
fields.DefineField(ClientFields.ClientName, 1, "Client");
fields.DefineField(ClientGroupFields.ClientGroupName, 2, "Group");
// Add all JOIN clauses to the relation collection
IRelationCollection relations = new RelationCollection();
// Create the DataTable, DAO and fill the DataTable with the above query definition/parameters
DataTable dt = new DataTable();
TypedListDAO dao = new TypedListDAO();
dao.GetMultiAsDataTable(fields, dt, 0, null, null, relations, false, null, null, 0, 0);
return dt;
While this seems like a lot of code to do something basic, the code almost writes itself once you're used to it and is vastly faster than writing plumbing. You'll never go back.
Use LinqMetaData
LinqMetaData metaData = new LinqMetaData();
if you use adapter mode
LinqMetaData metaData = new LinqMetaData(adapter);
var result = from a in metaData.TableA
join b in metaData.TableB on a.Key equals b.Key
where a.OtherField == value
select a;

VBA Edit Userform Listbox (based on excel database) using Checkboxes and Textboxes

I've a database (5 column's and the row's are adaptive). This data is sorted as: Name, Surname, Date of Birth and Promotion year.
I've also made an Userform based on a Listbox that can show this 4 informations.
Now i would like to edit this database using checkboxes and textboxes in the userform.
I already made my userform but the problem persists in transfering the data of the userform (checkbox: true or false and textbox) into the database on the corresponding cell (of the right person).
Any idea how I should think or work on this? I already tried some stuff but i can't show up with a solution that can transfer AND the checkbox AND the Textbox information.
Userform Layout
Assuming 5th column as A(status)
|Status|Name|Surname| DOB |Year|
Checkbx1 Data going to A(status)
Textbx1 Data going to B(Name)
Textbx2 Data going to C(Surname)
Textbx3 Data going to D(DOB)
Textbx4 Data going to E(Year)
"You may assign this code to a command button"
'Transfer of Data
If Form1.checkbox1=TRUE then
end if
'transferring Name to B
ActiveCell.Offset(0, 1).Value = StrConv(TextBox1, vbProperCase)
'transferring Surname to C
ActiveCell.Offset(0, 2).Value = StrConv(TextBox2, vbProperCase)
'transferring DOB to D
ActiveCell.Offset(0, 3).Value = StrConv(TextBox3, vbProperCase)
'transferring Year to E
ActiveCell.Offset(0, 4).Value = StrConv(TextBox4, vbProperCase)
You can use this code for populating the list
Private Sub UserForm_Initialize()
Sheets("Sheet1").Range(Sheets("Sheet1").UsedRange.Address).Name = "MyList"
ListBox1.ColumnCount = Range("MyList").Columns.Count
ListBox1.RowSource = "MyList"
End Sub
Then use below code to Find and Select the data row in Sheet
If ListBox1.ListIndex < 0 Then
MsgBox " Select a row first !"
Exit Sub
Cells.Find(What:=ListBox1.List(ListBox1.ListIndex), After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=True, SearchFormat:=False).Activate
Then use Offset for transferring the data from UserForm to the Sheet
ActiveCell.Offset(0, 4).Value = UserForm1.TextBox1.Text
ActiveCell.Offset(0, 5).Value = UserForm1.Checkbox1.value
ActiveCell.Offset(0, 6).Value = UserForm1.optionbutton1.value

Dropdown list in PowerBuilder can't retrieve all data

I have created in powerbuilder a dropdown data window to function as a filter to get values from a table named product and then by selecting something from the dropdown list in another datawindow to show all the retrieved data associated with the selection from the dropdown list.
Its working fine, the code in my w_firstwindow in open() is like that
datawindowchild child_data
if dw_prod_filter.getchild( 'productname', child_data ) = 1 then
child_data.settransobject( SQLCA )
child_data.retrieve( )
child_data.setitem( 1, 'name', 'ALL' )
child_data.setitem( 1, 'picture_name', 'ALL' )
child_data.selectrow( 0, false )
end if
in the datawindow filter dw_prod_filter in the itemchanged() I have this
string ls_product
ls_product = dw_prod_filter.GetItemString(row,'productname')
dw_product_list.retrieve( data )
and in the dw_product_list in the constructor() I have this
this.setTransObject( SQLCA )
I have made and the necessary retrieval arguments through power builder and is working fine.
I want when I select the ALL option from the dropdown list to retrieve the whole table product, I have tried many things with no luck,, and I was wondering if anyone can help me out, any help would be really appreciated,
Thank you in advance guys
What does the SQL statement for dw_product_list look like - specifically the WHERE clause?
In itemchanged()
string ls_product
ls_product = dw_prod_filter.GetItemString(row,'productname')
dw_product_list.retrieve( ls_product )
SELECT "product"."id", "product"."name", "product"."description", "product"."prod_size", "product"."color", "product"."quantity", "product"."unit_price", "product"."picture_name" FROM "product" WHERE ( "product"."name" = :name OR "product"."name" is null )

retrieving data in Power Builder

i am using PowerBuilder7.0 version.
I am working on inventory project.
i stucked in retrieving the value problem.
designed search button in main window -- code are -
//Clicked Event of Search Button on a Window
gs_srcharg.srchok = false
if gs_srcharg.srchok = false then // User has pressed Cancel Button
end if
dw_1.settaborder("item_code", 0)
i_newrec = false
dw_1.SetItem(dw_1.getrow(),"item_code", gs_srcharg.id)
dw_1.enabled = true
end of script
and w_srchemp's code --
string t_sqlst
string t_srchempcd
t_srchempcd = sle_empcd.text
t_sqlst = "select item_code from item_mast where item_code = '" + trim(t_srchempcd) + "'"
declare cur_srch dynamic cursor for SQLSA;
prepare SQLSA from :t_sqlst;
open dynamic cur_srch;
fetch cur_srch into :t_srchempcd;
// If document does not exists then
if sqlca.sqlcode <> 0 then
messagebox("Search Error", "This Item code does not exist")
close cur_srch;
sle_empcd.text = message.stringparm
end if
close cur_srch;
close(parent) //Close seach window
End of script
after this, whatever we search the code, we get value in main window but value is first row of table every time.
i want exact value, when we search. Please help ..
Why you are using cursor here for searching . You can directly call the sql query.
Long ll_item_code
select item_code INTO :ll_item_code
from item_mast
where item_code =long(trim(t_srchempcd))
And you are matching the item_code here and you are retrieving the same item code from SQL Query.
Check your SQL Query.
And if your sql statement gives more output , then you should use loop statements to get the appropriate results. So check for SQL Cursor on internet.
Why don't use a dynamic datastore? You can create it with:
new_syntax = "select item_code from item_mast where...."
dw_new.Create(new_syntax, error_create)
Well, now you easily can iterate the new datastore with a for cycle, filter, order...

jqgrid edittype select load value from data

I am using jqgrid in my new project.
In a specific case I need to use a select element in the grid. No problem.
I define the colModel and the column for example like (from wiki)
colModel : [
{name:'myname', edittype:'select', editoptions:{value:{1:'One',2:'Two'}} },
But now when I load my data I would prefer the column "myname" to contain the value 1.
This won't work for me instead it has to contain the value "One".
The problem with this is that the text-part of the select element is in my case localized in the business layer where the colModel is dynamically generated. Also the datatype for the entity which generates the data via EF 4 may not be a string. Then I have to find the correct localized text and manipulate the data result so that the column "myname" does not containt an integer which is typically the case but a string instead with the localized text.
There is no option you can use so that when the data contains the value which match an option in the select list then the grid finds that option and presents the text.
Now the grid presents the value as a text and first when I click edit it finds the matching option and presents the text. When I undo the edit it returns to present the value again.
I started to think of a solution and this is what I came up with. Please if you know a better solution or if you know there is a built in option don't hesitate to answer.
Otherwise here is what I did:
loadComplete: function (data) {
var colModel = grid.getGridParam('colModel');
$.each(colModel, function (index, col) {
if (col.edittype === 'select') {
$.each(grid.getDataIDs(), function (index, id) {
var row = grid.getRowData(id);
var value = row[col.name];
var editoptions = col.editoptions.value;
var startText = editoptions.indexOf(value + ':') + (value + ':').length;
var endText = editoptions.indexOf(';', startText);
if (endText === -1) { endText = editoptions.length; }
var text = editoptions.substring(startText, endText);
row[col.name] = text;
grid.setRowData(id, row);
It works and I will leave it like this if nobody comes up with a better way.
You should just include additional formatter:'select' option in the definition of the column. See the documentation for more details.