A5BLOBST a[o[[[[[[[[[ \\#\1\;\H\X\h\z\\\\\\\\\\\\ ]]]%])]9]H]S]W]a]q]]]]]]]]]]]]^^^#^,^7^A^J^[^k^p^v^^^^^^^^^^___(_5_C_F_P_[_e_w____________` `'`1`<`G`M`S`Z`a`q`z````````````a aaa-a7aBaKaQaWa\abaiaoaaaaaaaaaaaaab bbb!b,bFbcb}bbbbbbbbbcc#c*c6cL\kx (6FUal)3JQM^MvMMNN+N=NNNNNOO#OEOOOOP"P5P@PKP}PPPQDQvQQQQQ RR.R=RsRRRRRRRRSS"S/S=SKSaSoSSS#TiTU3UXKX:[R[\|t8|<Ldt4`L$ "@""p###$(%%d&P*p**+/T0@458::;<p<h@A@B8FFFGIHIJJ@KxKKKL@LlLLMNO`PPTQ(RDS TLUPYpYY0[\[[[[ \8\d\\\l]]^,^d^^^$__$`D```@axabdDee(gggg hLh !"#% '   $&(   *$&(+,6./01234578&(:;<JKLM INOPQRSTUVWXZ[\]^_ `aOPQRSTde [f ag .hijklm[deastust{|}~EFGHY b cn o pqrvwxyz !"#$u%&'( $&&)st.*\,-t.+&  /!#01.2.2/#$#$013 .2/#$$#05'(&+67#*p9     :\;<=>?@A8B./ 0-1-2-3-4-5-6-7-8-R>?@ABCD "%4&'()+a8 ,.C[ D!"D#$%&'#()*+E,-9.:;<=FG>#?@HAHBIC/DEJ&&L7#KR>?K@ABCD 12"%4&'(3+a8 ,K.M[ D!"D#$%&'#()*+N,-K9.:;<=O&>#?KK@PAPBIC/DEQS7#RR>?R@ABCD 12"%4&'(5+a8 ,R.M[ D!"D#$%&'#()*+N,-R9.:;<=O&>#?RR@TATBIC/DEUW7#VR>?V@ABCD 12"%4&'(7+a8 ,V.M[ D!"D#$%&'#()*+N,-V9.:;<=O&>#?VV@XAXBIC/DEYJ]EFGHY b cn o pqrvw^xyz 7#` t.LMNOPQ+&<S?ZI[[\K9a8:@_A_>@ABCD;12="%4&'(+ ,.[ D!"D#$%&'#()*+,-9.:;<=O&>#BIC/DEaRVJdEFGHY b cn o pqrvwexyz gS?bIcc\K?a8:@fAf>@ABCD@12="%4&'(+ ,.[ D!"D#$%&'#()*+,-9.:;<=O&>#BIC/DEhRV%0F4G6H8S>TAUB.tzu{|}~(`abcdenf ghoiBjklmpnqorpq+rsstsus'#v#w#(xyDvwxyzz{|} :WXY Zi[j\k]l^Em_;<EBF~UIIIKMO$7N7P t+sQ;<}EFGHY b cn o pqrvwxyz J]\  /!#1.2.2/#$#$13 .2/#$$#W7#p9     \<=>?@A8BT>?V@ABCDS1TU=VW4X'(Y+a8 ZV.M[ D!"D#$%&'#()*+N,-V9.:;<=O&>#?VV@ABIC/DERV%[U\!#$$#$$#$$#$$#$$#$$#$$#$$#$$ 0_1`2a3b4c5d6e7f8g%&'(4t5#6789:<ABGHI\PQRS]n^_Ebcdede q hijklmnopqs|}~ B  7*`abc denkghopq+rs'#v#w#(xyDv{wx .2#/y$$7 &1z4%~F   )-9=CV GHJLR] ^ Y            _     !"9h)*+,-./0123;ij=>?@CkDEFJlKLMNOTmUVWXYZ[\`oafpgrrtstuvwxyz{uvwx{|+}CC Group BasedC%4727664a-5c37-4911-b7d0-890c54f22d5fLC DD/MM/YYC MM/dd/yyyyLCGrid\Jbdim tmpl as p tmpl.ComponentName = "lowLevelDelete" tmpl.ComponentType = "Grid" tmpl.AjaxOn = .t. tmpl.LayoutColumns = 1 tmpl.SecurityModel = "Group Based" tmpl.SecurityMode = "" tmpl.PreCalcMode = "Standard" tmpl.clientSideDateFormat = "MM/dd/yyyy" tmpl.datePicker.dayNames = "Sun,Mon,Tue,Wed,Thu,Fri,Sat" tmpl.datePicker.firstDayOfWeek = 1 tmpl.datePicker.monthNames = "January,February,March,April,May,June,July,August,September,October,November,December" tmpl.datePicker.todayButtonText = "Today" tmpl.datePicker.closeButtonText = "Close" tmpl.publishedServerVariables = "" tmpl.customizationString.javascriptDialogs = "" tmpl.iconMapOverrides = "" tmpl.DataSourceType = "CS" tmpl.CS.database_type = "CS" tmpl.CS.type = "connectionstring" tmpl.cs.ConnectionString = "::name::sqlserver_alphasports" tmpl.CS.SQL = "SELECT [CUSTOMER_ID], [FIRSTNAME], [LASTNAME], [BILL_STATE_REGION] FROM [customer]" DIM tmpl.Arguments[0] AS P DIM tmpl.ArgumentsPage AS P with tmpl.ArgumentsPage .PromptTextAbove = "" end with tmpl.CS.PrimaryKeyColumns = "CUSTOMER_ID" tmpl.CS.IdentitySequenceName = "" tmpl.search.has_search_component = .t. tmpl.search.title = "Search " tmpl.search.show_title = .t. tmpl.search.search_button_label = "Search" tmpl.search.include_sorting_listbox = .t. tmpl.search.sort.prompt = "Sort by" tmpl.search.sorting_listbox_Label_position = "Left" tmpl.search.sort.promptInLineStyle = "" tmpl.search.sort.listbox.fieldname_prompt = "Select Field" tmpl.search.sort.listbox.use_column_headings = .f. tmpl.search.customSortDefinition = "" tmpl.search.sort.listbox.order_prompt = "Select Order" tmpl.search.sort.listbox.order_choices = "Ascending,Descending" tmpl.search.include_records_per_page_listbox = .t. tmpl.search.records_per_page.prompt = "Records per page" tmpl.search.records_per_page_Label_position = "Left" tmpl.search.records_per_page.promptInLineStyle = "" tmpl.search.records_per_page.listbox.value_prompt = "Select Value" tmpl.search.records_per_page.listbox.choices = "1,2,5,10,25,50,75,100" tmpl.search.orientation = "Vertical" tmpl.search.combine_criteria_using = 1 tmpl.search.style = 2 tmpl.search.allow_qbf_style = .t. tmpl.search.show_single_search_field = .f. tmpl.search.keyword_label = "Search for?" tmpl.search.has_Clear_link = .t. tmpl.search.Clear_link_Label = "Clear Search Criteria" tmpl.search.EnableShowHide = .f. tmpl.search.InitialState = "Open" tmpl.search.title_when_hidden = "Click here to search..." tmpl.search.toolbarPosition = "Below" tmpl.search.HideGridWhenNoActiveSearch = .f. tmpl.search.GridHTMLWhenHidden = "" tmpl.EditRegion.Search.Top = "" tmpl.EditRegion.Search.Bottom = "" tmpl.EditRegion.Search.Left = "" tmpl.EditRegion.Search.Right = "" tmpl.SearchFields = 1 DIM tmpl.SearchField_Info[tmpl.SearchFields] as P with tmpl.searchfield_info[1] .Fieldname = "BILL_STATE_REGION" .SearchExpression = "BILL_STATE_REGION" .Search_Style = 0 .KeywordSearch = .f. .Scope = "Local" .ConditionalStyle = "" .ConditionalStyleLevel = "Cell" .ClientSideConditionalStyle = "" .ClientSideConditionalStyleLevel = "Cell" .QBEDisable = .f. .QBEInlineStyle = "" .canBeUsedInWhereClause = .t. .autoincrement = .f. .portableType = "Character" .nativeType = "char" .Type = "C" .Varname = "BILL_STATE_REGION" .Column.LabelPosition = "Left" .Controltype = "TextBox" .Textbox.Size = 40 .Textbox.MaxLength = 200 .Textbox.InLineStyle = "" .hasWatermark= .f. .BreakType = "None" .nCols = 1 .Column.Hide = .f. .BaseFieldExpression = "BILL_STATE_REGION" .SourceAlias = "" .Column.Heading = "Bill State Region" end with tmpl.grid_layout_style = 1 tmpl.add_records_only = .f. tmpl.rows = 10 tmpl.suppress_empty_rows = .t. tmpl.has_row_separator = .t. tmpl.alternate_bands = .f. tmpl.even_band_size = 1 tmpl.odd_band_size = 1 tmpl.alternate_column_bands = .f. tmpl.even_column_band_size = 1 tmpl.odd_column_band_size = 1 tmpl.conditionalStyle = "" tmpl.clientSideConditionalStyle = "" tmpl.show_title = .f. tmpl.title = "" tmpl.FontSize = "Medium" tmpl.No_records_message = "No records in query" tmpl.total_records_row_position = 1 tmpl.total_records_row = "Records:  {Total_Records} " tmpl.show_column_titles = 1 tmpl.suppress_titles_if_no_records = .f. tmpl.show_row_labels = .t. tmpl.sort_style = 3 tmpl.reset_page_number_when_sorting = .t. tmpl.EditRegion.Grid.Top = <<%txt% %txt% tmpl.EditRegion.Grid.Bottom = <<%txt% %txt% tmpl.EditRegion.Grid.Left = <<%txt% %txt% tmpl.EditRegion.Grid.Right = <<%txt% %txt% tmpl.HasNewRecordsTitle = .f. tmpl.NewRecordsTitle = "New Records" tmpl.HasExistingRecordsTitle = .f. tmpl.ExistingRecordsTitle = "Existing Records" tmpl.Highlight_row_onHover = .t. tmpl.Highlight_row_onSelect = .t. tmpl.HasRecordsPerPageSelector = .t. tmpl.RecordsPerPageChoices = "1,2,5,10,25,50,75,100" tmpl.RecordsPerPageSelectorTemplate = "  {Grid.RecordsPerPageSelector} Records per page" tmpl.XbasicFunctionDeclarations = <<%txt% function lowLevelDelete as c (e as p) debug(1) 'this function will do the following dim currentState as c 'note - since this grid is NOT editable, by default data from the current row is NOT submitted 'when the callback is made (the Primary Key is submitted). 'So, e._currentRowData will be empty, UNLESS you check the 'compute current row data' checkbox 'when defining the ajax callback in action javascript currentState = e._currentRowDataNew.bill_state_region 'ok, now that we have the state value for the current row, let's do an AlphaDAO query to see how 'many customers there are in this state dim cn as sql::connection dim cs as c 'get the connection string that is defined in this Grid component cs = e.tmpl.cs.connectionString dim flag as l flag = cn.open(cs) if flag = .f. then dim msg as c msg = "Could not connect to database. Error reported was: " + cn.CallResult.text 'we need to encode this for javascript since the message will be sent back to the browser for display 'js_escape() encodes ' as \' and crlf as \n msg = js_escape(msg) dim jscmd as c 'create the javascript command to send back to the browser. this command will 'display a javascript alert box. 'at this point we are done, so exit the function and return jscmd. 'note that in xbasic the way a function returns a value is you set the function name to the value 'you want to return. jscmd = "alert('" + msg + "');" lowLevelDelete = jscmd exit function end if dim sql as c 'note that the sql uses an argument in the where clause. arguments start with : sql = "select count(*) from customer where bill_state_region = :whatState" dim args as sql::arguments 'set the value of the 'whatState' argument. args.add("whatState",currentState) flag = cn.Execute(sql,args) if flag = .f. then 'there was an error - close the connection and exit cn.Close() dim msg as c msg = "Could execute count query. Error reported was: " + cn.CallResult.text msg = js_escape(msg) dim jscmd as c jscmd = "alert('" + msg + "');" lowLevelDelete = jscmd exit function end if dim rs as sql::resultset rs = cn.ResultSet dim recordCount as n 'since we executed a count query, the resultset will only have one column - which holds the count 'read the data in the first (and only) column of the resultset recordCount = rs.data(1) 'the arbitrary rule I have is that you can't delete a record if there are fewer than '5 records from the same state if recordCount < 5 then cn.close() dim msg as c msg = "You can't delete this record because we have an arbitrary rule that says you can only delete a record if more than 5 records from the same state exist." msg = js_escape(msg) dim jscmd as c jscmd = "alert('" + msg + "');" lowLevelDelete = jscmd exit function end if 'ok, if we get to this point, then it is ok to delete the record. 'the primary key of the current row is always stored in 'e._currentRowKeys. This is an array with values for each column in the primary key. 'in this case the primary key is a single column - customerId. 'so to get the value of the primary key, we read the first (and in this case only) array value. 'had the primary key consisted of multiple columns (e.g. firstname and lastname), then the array 'would have had two values. dim pkValue as c pkValue = e._currentRowKeys[1] dim sqldelete as c sqldelete = "delete from customer where customer_Id = :whatCustomerId" 'delete the existing args object (not strictly necessary) delete args dim args as sql::arguments 'set the value of the 'whatCustomerid' argument. This must be numeric type args.add("whatCustomerId", convert_type(pkValue,"N")) flag = cn.Execute(sqldelete,args) if flag = .f. then 'there was an error - close the connection and exit cn.Close() dim msg as c msg = "Could not delete record. Error reported was: " + cn.CallResult.text msg = js_escape(msg) dim jscmd as c jscmd = "alert('" + msg + "');" lowLevelDelete = jscmd exit function end if dim rowsAffected as n rowsAffected = cn.affectedrows() if rowsAffected = 0 then 'no records were actually deleted cn.Close() dim msg as c msg = "Record to delete was not found. No records were deleted." msg = js_escape(msg) dim jscmd as c jscmd = "alert('" + msg + "');" lowLevelDelete = jscmd exit function end if 'if you get here, then the record was deleted from the underlying table, 'however, the grid has not been refreshed, so the deleted record is still being displayed. 'the easiest way to refresh the grid would be to do a full refresh (by calling the 'Grid object's .refresh() method dim jscmd as c = "" 'notice that we use the special placeholder '{grid.object}'. at runtime this will be replaced 'with the Grid's actual object name. jscmd = jscmd + "{grid.object}.refresh();" 'let's also add an optional message jscmd = jscmd + "alert('Record was deleted');" lowLevelDelete = jscmd 'This function will handle the Ajax callback. 'It must return a string of Javscript commands that will be executed in the Browser. 'The 'e' object contains all of the data that is submitted in the Ajax callback. 'In addition, the 'e' object contains: 'e._currentRowDataOld - (only if the grid is editable) - original value in the current row before field was edited. ' examples: e._currentRowDataOld.lastname, e._currentRowDataOld.firstname 'e._currentRowDataNew as p - current field values in the current row. ' examples: e._currentRowDataNew.lastname, e._currentRowDataNew.firstname 'e._currentRowKeys - an array containing primary key field values for the current row ' example: If the primary key for the table that the grid is based on is 'Lastname' and 'Firstname', ' e._currentRowKeys[1] will contain the value for 'Lastname' and e._currentRowKeys[2] will contain the value for 'Firstname' 'In addition, the 'e' object contains: 'e.tmpl - the Component definition 'e.session - session variables 'e.__si - state information that is stored in a hidden field in the component. 'e.rtc - holds runtime calculations that are performed when component is executing. 'If you set certain properties in 'e._set' then the appropriate Javascript code will be automatically generated in the Ajax response 'Examples: 'e._set.lastname.value = "Smith" --- will set the value of the 'Lastnme' field in the current row to "Smith" 'e._set.lastname.style = "color: red;" --- will set the style attribute for the 'Lastname' field in the current row. 'e._set.lastname.className = "NewClassName" --- will set the ClassName attribute of the 'Lastname' field in the current row. 'e._set.firstname.style.color = "red" --- will set the style.color attribute to 'Red' (preserving all other style attributes that had been set) 'e._set.firstname.style.fontSize = "20pt" -- will set the style.fontSize attribute to '20pt' (preserving all other style attributes that had been set) (Important: the name of the style attribute is case-sensitive) 'Note: 'Assume your callback submitted data from the 'Grid' part, row 3: 'e._set.lastname.value = "Smith" gets converted to this Javascript code: '{grid.object}._setValue('G','LASTNAME',3,'' + 'Smith',true);' and this code is automatically added to the Ajax response. 'Note: 'In addition to 'e._set', you can set properties of the 'e._setElement', 'e._setGridElement' and 'e._setRow' objects. 'Examples: 'e._setRow3.lastname.value = "Smith" 'e._setRow_1.firstname.value = "John" --- sets the value in the first New Record row 'e._setElement.DIV1.value = "Some text" --- sets the innerHTML of DIV with the id of 'DIV1' 'e._setGridElement.SPN2.style.color = "Red" ---- sets style properties of a SPAN with id of '{grid.componentname}.SPN2' 'example code: 'Return a Javascript command 'lowLevelDelete = "alert('You submitted a value of: " + js_escape(e._currentRowDataNew.lastname) + "');" end function function DeleteWithPrompt as c (e as p) dim currentState as c 'note - since this grid is NOT editable, by default data from the current row is NOT submitted 'when the callback is made (the Primary Key is submitted). 'So, e._currentRowData will be empty, UNLESS you check the 'compute current row data' checkbox 'when defining the ajax callback in action javascript currentState = e._currentRowDataNew.bill_state_region 'ok, now that we have the state value for the current row, let's do an AlphaDAO query to see how 'many customers there are in this state dim cn as sql::connection dim cs as c 'get the connection string that is defined in this Grid component cs = e.tmpl.cs.connectionString dim flag as l flag = cn.open(cs) if flag = .f. then dim msg as c msg = "Could not connect to database. Error reported was: " + cn.CallResult.text 'we need to encode this for javascript since the message will be sent back to the browser for display 'js_escape() encodes ' as \' and crlf as \n msg = js_escape(msg) dim jscmd as c 'create the javascript command to send back to the browser. this command will 'display a javascript alert box. 'at this point we are done, so exit the function and return jscmd. 'note that in xbasic the way a function returns a value is you set the function name to the value 'you want to return. jscmd = "alert('" + msg + "');" lowLevelDelete = jscmd exit function end if dim sql as c 'note that the sql uses an argument in the where clause. arguments start with : sql = "select count(*) from customer where bill_state_region = :whatState" dim args as sql::arguments 'set the value of the 'whatState' argument. args.add("whatState",currentState) flag = cn.Execute(sql,args) if flag = .f. then 'there was an error - close the connection and exit cn.Close() dim msg as c msg = "Could execute count query. Error reported was: " + cn.CallResult.text msg = js_escape(msg) dim jscmd as c jscmd = "alert('" + msg + "');" lowLevelDelete = jscmd exit function end if dim rs as sql::resultset rs = cn.ResultSet dim recordCount as n 'since we executed a count query, the resultset will only have one column - which holds the count 'read the data in the first (and only) column of the resultset recordCount = rs.data(1) 'the arbitrary rule I have is that you can't delete a record if there are fewer than '5 records from the same state if recordCount < 5 then cn.close() dim msg as c msg = "You can't delete this record because we have an arbitrary rule that says you can only delete a record if more than 5 records from the same state exist." msg = js_escape(msg) dim jscmd as c jscmd = "alert('" + msg + "');" lowLevelDelete = jscmd exit function end if 'ok, if we get to this point, then it is ok to delete the record. dim jscmd as c jscmd = <<%js% var answer = confirm('OK to delete this record?'); if(answer == true) { {grid.Object}.ajaxCallback('G',{Grid.RowNumber},'DoDelete','','_getData=true'); } else { alert('Record will not be deleted'); } %js% DeleteWithPrompt = jscmd end function function DoDelete as c (e as p) currentState = e._currentRowDataNew.bill_state_region dim cn as sql::connection dim cs as c cs = e.tmpl.cs.connectionString dim flag as l flag = cn.open(cs) if flag = .f. then dim msg as c msg = "Could not connect to database. Error reported was: " + cn.CallResult.text msg = js_escape(msg) dim jscmd as c jscmd = "alert('" + msg + "');" DoDelete = jscmd exit function end if dim args as sql::arguments dim pkValue as c pkValue = e._currentRowKeys[1] dim sqldelete as c sqldelete = "delete from customer where customer_Id = :whatCustomerId" args.add("whatCustomerId", convert_type(pkValue,"N")) flag = cn.Execute(sqldelete,args) if flag = .f. then 'there was an error - close the connection and exit cn.Close() dim msg as c msg = "Could not delete record. Error reported was: " + cn.CallResult.text msg = js_escape(msg) dim jscmd as c jscmd = "alert('" + msg + "');" DoDelete = jscmd exit function end if dim rowsAffected as n rowsAffected = cn.affectedrows() if rowsAffected = 0 then 'no records were actually deleted cn.Close() dim msg as c msg = "Record to delete was not found. No records were deleted." msg = js_escape(msg) dim jscmd as c jscmd = "alert('" + msg + "');" DoDelete = jscmd exit function end if dim jscmd as c = "" jscmd = jscmd + "{grid.object}.refresh();" 'let's also add an optional message jscmd = jscmd + "alert('Record was deleted');" doDelete = jscmd end function %txt% tmpl.has_qbe_row = .f. tmpl.qbe.initial_display = "Hidden" tmpl.qbe.toggleQBERowHyperlinkText = "Show/Hide QBE Row" tmpl.hasLinkedContent = .f. tmpl.hasExternalNavigators = .f. tmpl.hasRowExpandColumn = .f. tmpl.hasSelectedRowColumn = .t. tmpl.hasCheckboxSelectColumn = .f. tmpl.AdditionalGridStyles = "" tmpl.LocalCss = "" tmpl.CSSLinkedFiles = "" tmpl.JavaScriptLinkedFiles = "" tmpl.useMasterTemplate = .f. tmpl.MasterTemplateStyle = "Table - Vertical Layout" tmpl.MasterLayoutTemplate = "" tmpl.MasterLayoutTemplateJavascript = "" tmpl.MasterLayout.PaneLabel.Search = "Search" tmpl.MasterLayout.PaneLabel.Grid = "Grid" tmpl.MasterLayout.PaneLabel.DetailView = "Detail" tmpl.MasterLayout.AccordionStyle = "Multiple" tmpl.MasterLayout.InitialOpenPanes = "Search,Grid,DetailView" tmpl.CanCollapseGrid = .f. tmpl.CollapseBar.Title = "Collapse Grid" tmpl.CollapseBar.OpenIcon = "" tmpl.CollapseBar.ClosedIcon = "" tmpl.CollapseBar.Style = "" tmpl.Collapsebar.Class = "" tmpl.Collapsebar.ContainerStyle = "" tmpl.Collapsebar.ContainerClass = "" tmpl.Collapsebar.InitialState = "open" tmpl.fields = 6 DIM tmpl.field_info[tmpl.fields] as P with tmpl.field_info[1] .Fieldname = "CUSTOMER_ID" .Scope = "Local" .DisplayFormat = "" .DisplayUnFormat = "" .ConditionalStyle = "" .ConditionalStyleLevel = "Cell" .ClientSideConditionalStyle = "" .ClientSideConditionalStyleLevel = "Cell" .QBEDisable = .f. .QBEInlineStyle = "" .canBeUsedInWhereClause = .t. .autoincrement = .t. .portableType = "Number" .nativeType = "numeric" .Type = "N" .Varname = "CUSTOMER_ID" .Column.LabelPosition = "Left" .Controltype = "Label" .Label.InLineStyle = "text-align: right;" .BreakType = "None" .nCols = 1 .Column.Hide = .f. .BaseFieldExpression = "CUSTOMER_ID" .SourceAlias = "" .Column.Heading = "Customer Id" .Column.Sort = "CUSTOMER_ID" end with with tmpl.field_info[2] .Fieldname = "FIRSTNAME" .Scope = "Local" .DisplayFormat = "" .DisplayUnFormat = "" .ConditionalStyle = "" .ConditionalStyleLevel = "Cell" .ClientSideConditionalStyle = "" .ClientSideConditionalStyleLevel = "Cell" .QBEDisable = .f. .QBEInlineStyle = "" .canBeUsedInWhereClause = .t. .autoincrement = .f. .portableType = "Character" .nativeType = "char" .Type = "C" .Varname = "FIRSTNAME" .Column.LabelPosition = "Left" .Controltype = "Label" .Label.InLineStyle = "" .BreakType = "None" .nCols = 1 .Column.Hide = .f. .BaseFieldExpression = "FIRSTNAME" .SourceAlias = "" .Column.Heading = "Firstname" .Column.Sort = "FIRSTNAME" end with with tmpl.field_info[3] .Fieldname = "LASTNAME" .Scope = "Local" .DisplayFormat = "" .DisplayUnFormat = "" .ConditionalStyle = "" .ConditionalStyleLevel = "Cell" .ClientSideConditionalStyle = "" .ClientSideConditionalStyleLevel = "Cell" .QBEDisable = .f. .QBEInlineStyle = "" .canBeUsedInWhereClause = .t. .autoincrement = .f. .portableType = "Character" .nativeType = "char" .Type = "C" .Varname = "LASTNAME" .Column.LabelPosition = "Left" .Controltype = "Label" .Label.InLineStyle = "" .BreakType = "None" .nCols = 1 .Column.Hide = .f. .BaseFieldExpression = "LASTNAME" .SourceAlias = "" .Column.Heading = "Lastname" .Column.Sort = "LASTNAME" end with with tmpl.field_info[4] .Fieldname = "BILL_STATE_REGION" .Scope = "Local" .DisplayFormat = "" .DisplayUnFormat = "" .ConditionalStyle = "" .ConditionalStyleLevel = "Cell" .ClientSideConditionalStyle = "" .ClientSideConditionalStyleLevel = "Cell" .QBEDisable = .f. .QBEInlineStyle = "" .canBeUsedInWhereClause = .t. .autoincrement = .f. .portableType = "Character" .nativeType = "char" .Type = "C" .Varname = "BILL_STATE_REGION" .Column.LabelPosition = "Left" .Controltype = "Label" .Label.InLineStyle = "" .BreakType = "None" .nCols = 1 .Column.Hide = .f. .BaseFieldExpression = "BILL_STATE_REGION" .SourceAlias = "" .Column.Heading = "Bill State Region" .Column.Sort = "BILL_STATE_REGION" end with with tmpl.field_info[5] .Controltype = "Unbound_Button" .Fieldname = "_Unbound_Button_1" .Varname = "_Unbound_Button_1" .ButtonText = "DeleteRecordLowLevel" .Button.class = "" .Button.style = "" .Column.CanSort = .t. .Column.Sort = "" .Column.Heading = "" .Column.InLineStyle = "" .Column.LabelInLineStyle = "" .Column.heading_left = "" .Column.Hide = .f. .BreakType = "None" .Column.LabelPosition = "Left" .nCols = 1 .javascript.onclick = <<%txt% /* actionJavascript:fff73908-8a17-4181-b015-22c2e5d13b99 */ {grid.Object}.ajaxCallback('G',{Grid.RowNumber},'lowLevelDelete','','_getData=true');%txt% end with with tmpl.field_info[6] .Controltype = "Unbound_Button" .Fieldname = "_Unbound_Button_2" .Varname = "_Unbound_Button_2" .ButtonText = "DeleteWithPromptForConfirmation" .Button.class = "" .Button.style = "" .Column.CanSort = .t. .Column.Sort = "" .Column.Heading = "" .Column.InLineStyle = "" .Column.LabelInLineStyle = "" .Column.heading_left = "" .Column.Hide = .f. .BreakType = "None" .Column.LabelPosition = "Left" .nCols = 1 .javascript.onclick = <<%txt% /* actionJavascript:7dde31ba-f6b7-49bf-bac7-f78ee75d9802 */ {grid.Object}.ajaxCallback('G',{Grid.RowNumber},'DeleteWithPrompt','','_getData=true');%txt% end with tmpl.RecNav.SuppressIfOnlyOnePage = .t. tmpl.RecNav.First_Label = "First" tmpl.RecNav.Has_First_Button = .t. tmpl.RecNav.Has_Last_Button = .t. tmpl.RecNav.Has_Next_Button = .t. tmpl.RecNav.Has_Prev_Button = .t. tmpl.RecNav.HTML_Template_source = "Computed" tmpl.RecNav.Justify = "Left" tmpl.RecNav.Last_Label = "Last" tmpl.RecNav.Next_Label = "Next" tmpl.RecNav.Number_of_page_links = 10 tmpl.RecNav.Page_Numbering_Style = 3 tmpl.RecNav.PagesTemplate_w_PageCount = "{PageNumber} of {PageCount}" tmpl.RecNav.PagesTemplate_wout_PageCount = "{PageNumber}" tmpl.RecNav.Position = 1 tmpl.RecNav.suppress_recNavBar_if_no_records = .f. tmpl.RecNav.Prev_Label = "Prev" tmpl.RecNav.Show_disabled_controls = .t. tmpl.RecNav.Show_Page_Count = .t. tmpl.RecNav.Use_Images = .f. tmpl.gridToolbarTemplate = <<%html% %html% tmpl.gridToolbarTemplateEditable = <<%html% %html% tmpl.style_name = "GlassBlue" tmpl.UseSimpleStyles = .f. tmpl.overrideStylesForJavascriptObjects = .f. tmpl.GUID = "4727664a-5c37-4911-b7d0-890c54f22d5f" tmpl.onlyIncludeSelectedFieldsInQuery = .t. tmpl.actionJSMetadata = <<%txt% %str%> > > > <[2] %str%> > > > > %txt%N@ClowLevelDeleteN?PCsqlserver_alphasportsC customerCCSC CUSTOMER_ID\# > <[2] > <[3] > <[4] > <[5] > <[6] > <[7] > <[8] > <[9] > <[10] > <[11] > <[12] > <[13] > <[14] > <[15] > <[16] > <[17] > <[18] > <[19] > <[20] > <[21] > > CY > > CTableC AscendingC Tab labelCTabCTopCSingleCAfterC Frame LabelCSimpleCShownCButtonC HyperlinkC.1inCLabelCFrom:CTo:NCtext-align: right;C mm/dd/yyN4@Nx@N@C CMaskN@C1inC2inCfont: 9pt Arial;C DBF-TableC Add to ListC HorizontalCStaticCFalseCAccess DatabaseC C Customer IdCLeftCNoneCborder-style: none;CValue in FieldCField value is link addressC Modal-PopupCWindowC3inC4inC Working...CCSS/A5System/images/wait.gifCCloseCNCCellCnumericCNumberN"@CF{F=Tahoma,8}{I:'a5_blue_text'}{T=.2}{C=}{DATA=CUSTOMER_ID}CUSTOMER_IDCLocalC$with tmpl.field_info[_fieldNumber_] .Fieldname = "CUSTOMER_ID" .Scope = "Local" .DisplayFormat = "" .DisplayUnFormat = "" .ConditionalStyle = "" .ConditionalStyleLevel = "Cell" .ClientSideConditionalStyle = "" .ClientSideConditionalStyleLevel = "Cell" .QBEDisable = .f. .QBEInlineStyle = "" .canBeUsedInWhereClause = .t. .autoincrement = .t. .portableType = "Number" .nativeType = "numeric" .Type = "N" .Varname = "CUSTOMER_ID" .Column.LabelPosition = "Left" .Controltype = "Label" .Label.InLineStyle = "text-align: right;" .BreakType = "None" .nCols = 1 .Column.Hide = .f. .BaseFieldExpression = "CUSTOMER_ID" .SourceAlias = "" .Column.Heading = "Customer Id" .Column.Sort = "CUSTOMER_ID" end with C FIRSTNAMEC FirstnameCCCcharC CharacterCB{F=Tahoma,8}{I:'a5_blue_text'}{T=.2}{C=}{DATA=FIRSTNAME}FIRSTNAMECwith tmpl.field_info[_fieldNumber_] .Fieldname = "FIRSTNAME" .Scope = "Local" .DisplayFormat = "" .DisplayUnFormat = "" .ConditionalStyle = "" .ConditionalStyleLevel = "Cell" .ClientSideConditionalStyle = "" .ClientSideConditionalStyleLevel = "Cell" .QBEDisable = .f. .QBEInlineStyle = "" .canBeUsedInWhereClause = .t. .autoincrement = .f. .portableType = "Character" .nativeType = "char" .Type = "C" .Varname = "FIRSTNAME" .Column.LabelPosition = "Left" .Controltype = "Label" .Label.InLineStyle = "" .BreakType = "None" .nCols = 1 .Column.Hide = .f. .BaseFieldExpression = "FIRSTNAME" .SourceAlias = "" .Column.Heading = "Firstname" .Column.Sort = "FIRSTNAME" end with C LASTNAMEC LastnameC@{F=Tahoma,8}{I:'a5_blue_text'}{T=.2}{C=}{DATA=LASTNAME}LASTNAMECwith tmpl.field_info[_fieldNumber_] .Fieldname = "LASTNAME" .Scope = "Local" .DisplayFormat = "" .DisplayUnFormat = "" .ConditionalStyle = "" .ConditionalStyleLevel = "Cell" .ClientSideConditionalStyle = "" .ClientSideConditionalStyleLevel = "Cell" .QBEDisable = .f. .QBEInlineStyle = "" .canBeUsedInWhereClause = .t. .autoincrement = .f. .portableType = "Character" .nativeType = "char" .Type = "C" .Varname = "LASTNAME" .Column.LabelPosition = "Left" .Controltype = "Label" .Label.InLineStyle = "" .BreakType = "None" .nCols = 1 .Column.Hide = .f. .BaseFieldExpression = "LASTNAME" .SourceAlias = "" .Column.Heading = "Lastname" .Column.Sort = "LASTNAME" end with CBILL_STATE_REGIONCBill State RegionCR{F=Tahoma,8}{I:'a5_blue_text'}{T=.2}{C=}{DATA=BILL_STATE_REGION}BILL_STATE_REGIONC0with tmpl.field_info[_fieldNumber_] .Fieldname = "BILL_STATE_REGION" .Scope = "Local" .DisplayFormat = "" .DisplayUnFormat = "" .ConditionalStyle = "" .ConditionalStyleLevel = "Cell" .ClientSideConditionalStyle = "" .ClientSideConditionalStyleLevel = "Cell" .QBEDisable = .f. .QBEInlineStyle = "" .canBeUsedInWhereClause = .t. .autoincrement = .f. .portableType = "Character" .nativeType = "char" .Type = "C" .Varname = "BILL_STATE_REGION" .Column.LabelPosition = "Left" .Controltype = "Label" .Label.InLineStyle = "" .BreakType = "None" .nCols = 1 .Column.Hide = .f. .BaseFieldExpression = "BILL_STATE_REGION" .SourceAlias = "" .Column.Heading = "Bill State Region" .Column.Sort = "BILL_STATE_REGION" end with C_Unbound_Button_1C [Button].1Clayout_directive_buttonC1CDeleteRecordLowLevelCH{F=Tahoma,8}{I:'$$control.button'}{T=.2}{C=}{DATA=[Button].1}[Button].1C/* actionJavascript:fff73908-8a17-4181-b015-22c2e5d13b99 */ {grid.Object}.ajaxCallback('G',{Grid.RowNumber},'lowLevelDelete','','_getData=true');Cwith tmpl.field_info[_fieldNumber_] .Controltype = "Unbound_Button" .Fieldname = "_Unbound_Button_1" .Varname = "_Unbound_Button_1" .ButtonText = "DeleteRecordLowLevel" .Button.class = "" .Button.style = "" .Column.CanSort = .t. .Column.Sort = "" .Column.Heading = "" .Column.InLineStyle = "" .Column.LabelInLineStyle = "" .Column.heading_left = "" .Column.Hide = .f. .BreakType = "None" .Column.LabelPosition = "Left" .nCols = 1 .javascript.onclick = <<%txt% /* actionJavascript:fff73908-8a17-4181-b015-22c2e5d13b99 */ {grid.Object}.ajaxCallback('G',{Grid.RowNumber},'lowLevelDelete','','_getData=true');%txt% end with C_Unbound_Button_2C [Button].2C2C DeleteWithPromptForConfirmationCH{F=Tahoma,8}{I:'$$control.button'}{T=.2}{C=}{DATA=[Button].2}[Button].2C/* actionJavascript:7dde31ba-f6b7-49bf-bac7-f78ee75d9802 */ {grid.Object}.ajaxCallback('G',{Grid.RowNumber},'DeleteWithPrompt','','_getData=true');Cwith tmpl.field_info[_fieldNumber_] .Controltype = "Unbound_Button" .Fieldname = "_Unbound_Button_2" .Varname = "_Unbound_Button_2" .ButtonText = "DeleteWithPromptForConfirmation" .Button.class = "" .Button.style = "" .Column.CanSort = .t. .Column.Sort = "" .Column.Heading = "" .Column.InLineStyle = "" .Column.LabelInLineStyle = "" .Column.heading_left = "" .Column.Hide = .f. .BreakType = "None" .Column.LabelPosition = "Left" .nCols = 1 .javascript.onclick = <<%txt% /* actionJavascript:7dde31ba-f6b7-49bf-bac7-f78ee75d9802 */ {grid.Object}.ajaxCallback('G',{Grid.RowNumber},'DeleteWithPrompt','','_getData=true');%txt% end with C New RecordCSaveCDeleteCAddC Detail View CDirty Fields OnlyCCancelCUpdate record?CDelete record?C Add record?CCIconC#images/$$generic.error.png.a5imageC AutoSelectCErrorsC%color: red; width: 6in; height: 2in;C First recordC Current pageCIconsCInitiallyEditableCBelowC LayoutOnlyCOnPageNR@C Detail ViewCClick a hyperlink fieldC ComputedCSearch CClick here to search...CSearchCGetC Sort byC Select FieldC Select OrderCAscending,DescendingCRecords per pageC Select ValueC1,2,5,10,25,50,75,100C VerticalC Search for?CClear Search CriteriaCOpenC Above TitlesCimages/$$filter.png.a5imageCShow/hide the Search PartCSearch for recordsCClear search criteriaC$images/$$filter.records.png.a5imageC"images/$$filter.clear.png.a5imageC!Free-form region for each columnCTextBoxND@Ni@CEdit-Combo ListCAdd To List if Not NullCBill_State_RegionCR{F=Tahoma,8}{I:'$a5_control_field'} {C=}{DATA=BILL_STATE_REGION}BILL_STATE_REGIONCW{F=Tahoma,8}{I:'$a5_control_field'}{T=.2}{C=}{DATA=BILL_STATE_REGION}BILL_STATE_REGIONCSwith tmpl.searchfield_info[_fieldNumber_] .Fieldname = "BILL_STATE_REGION" .SearchExpression = "BILL_STATE_REGION" .Search_Style = 0 .KeywordSearch = .f. .Scope = "Local" .ConditionalStyle = "" .ConditionalStyleLevel = "Cell" .ClientSideConditionalStyle = "" .ClientSideConditionalStyleLevel = "Cell" .QBEDisable = .f. .QBEInlineStyle = "" .canBeUsedInWhereClause = .t. .autoincrement = .f. .portableType = "Character" .nativeType = "char" .Type = "C" .Varname = "BILL_STATE_REGION" .Column.LabelPosition = "Left" .Controltype = "TextBox" .Textbox.Size = 40 .Textbox.MaxLength = 200 .Textbox.InLineStyle = "" .hasWatermark= .f. .BreakType = "None" .nCols = 1 .Column.Hide = .f. .BaseFieldExpression = "BILL_STATE_REGION" .SourceAlias = "" .Column.Heading = "Bill State Region" end with C GlassBlueC StandardCMediumCDefaultN$@CTBLRC%Records:  {Total_Records} C AutomaticCNo records in queryCTotalCCountCAverageCMinimumCMaximumC Std. Dev.C VarianceCFirstCLastC2Total,Count,Average,Min,Max,StdDev,Var,First,LastCgNew RecordsClExisting RecordsC_C;  {Grid.RecordsPerPageSelector} Records per pageCAllCAlphabet Buttons\2function lowLevelDelete as c (e as p) debug(1) 'this function will do the following dim currentState as c 'note - since this grid is NOT editable, by default data from the current row is NOT submitted 'when the callback is made (the Primary Key is submitted). 'So, e._currentRowData will be empty, UNLESS you check the 'compute current row data' checkbox 'when defining the ajax callback in action javascript currentState = e._currentRowDataNew.bill_state_region 'ok, now that we have the state value for the current row, let's do an AlphaDAO query to see how 'many customers there are in this state dim cn as sql::connection dim cs as c 'get the connection string that is defined in this Grid component cs = e.tmpl.cs.connectionString dim flag as l flag = cn.open(cs) if flag = .f. then dim msg as c msg = "Could not connect to database. Error reported was: " + cn.CallResult.text 'we need to encode this for javascript since the message will be sent back to the browser for display 'js_escape() encodes ' as \' and crlf as \n msg = js_escape(msg) dim jscmd as c 'create the javascript command to send back to the browser. this command will 'display a javascript alert box. 'at this point we are done, so exit the function and return jscmd. 'note that in xbasic the way a function returns a value is you set the function name to the value 'you want to return. jscmd = "alert('" + msg + "');" lowLevelDelete = jscmd exit function end if dim sql as c 'note that the sql uses an argument in the where clause. arguments start with : sql = "select count(*) from customer where bill_state_region = :whatState" dim args as sql::arguments 'set the value of the 'whatState' argument. args.add("whatState",currentState) flag = cn.Execute(sql,args) if flag = .f. then 'there was an error - close the connection and exit cn.Close() dim msg as c msg = "Could execute count query. Error reported was: " + cn.CallResult.text msg = js_escape(msg) dim jscmd as c jscmd = "alert('" + msg + "');" lowLevelDelete = jscmd exit function end if dim rs as sql::resultset rs = cn.ResultSet dim recordCount as n 'since we executed a count query, the resultset will only have one column - which holds the count 'read the data in the first (and only) column of the resultset recordCount = rs.data(1) 'the arbitrary rule I have is that you can't delete a record if there are fewer than '5 records from the same state if recordCount < 5 then cn.close() dim msg as c msg = "You can't delete this record because we have an arbitrary rule that says you can only delete a record if more than 5 records from the same state exist." msg = js_escape(msg) dim jscmd as c jscmd = "alert('" + msg + "');" lowLevelDelete = jscmd exit function end if 'ok, if we get to this point, then it is ok to delete the record. 'the primary key of the current row is always stored in 'e._currentRowKeys. This is an array with values for each column in the primary key. 'in this case the primary key is a single column - customerId. 'so to get the value of the primary key, we read the first (and in this case only) array value. 'had the primary key consisted of multiple columns (e.g. firstname and lastname), then the array 'would have had two values. dim pkValue as c pkValue = e._currentRowKeys[1] dim sqldelete as c sqldelete = "delete from customer where customer_Id = :whatCustomerId" 'delete the existing args object (not strictly necessary) delete args dim args as sql::arguments 'set the value of the 'whatCustomerid' argument. This must be numeric type args.add("whatCustomerId", convert_type(pkValue,"N")) flag = cn.Execute(sqldelete,args) if flag = .f. then 'there was an error - close the connection and exit cn.Close() dim msg as c msg = "Could not delete record. Error reported was: " + cn.CallResult.text msg = js_escape(msg) dim jscmd as c jscmd = "alert('" + msg + "');" lowLevelDelete = jscmd exit function end if dim rowsAffected as n rowsAffected = cn.affectedrows() if rowsAffected = 0 then 'no records were actually deleted cn.Close() dim msg as c msg = "Record to delete was not found. No records were deleted." msg = js_escape(msg) dim jscmd as c jscmd = "alert('" + msg + "');" lowLevelDelete = jscmd exit function end if 'if you get here, then the record was deleted from the underlying table, 'however, the grid has not been refreshed, so the deleted record is still being displayed. 'the easiest way to refresh the grid would be to do a full refresh (by calling the 'Grid object's .refresh() method dim jscmd as c = "" 'notice that we use the special placeholder '{grid.object}'. at runtime this will be replaced 'with the Grid's actual object name. jscmd = jscmd + "{grid.object}.refresh();" 'let's also add an optional message jscmd = jscmd + "alert('Record was deleted');" lowLevelDelete = jscmd 'This function will handle the Ajax callback. 'It must return a string of Javscript commands that will be executed in the Browser. 'The 'e' object contains all of the data that is submitted in the Ajax callback. 'In addition, the 'e' object contains: 'e._currentRowDataOld - (only if the grid is editable) - original value in the current row before field was edited. ' examples: e._currentRowDataOld.lastname, e._currentRowDataOld.firstname 'e._currentRowDataNew as p - current field values in the current row. ' examples: e._currentRowDataNew.lastname, e._currentRowDataNew.firstname 'e._currentRowKeys - an array containing primary key field values for the current row ' example: If the primary key for the table that the grid is based on is 'Lastname' and 'Firstname', ' e._currentRowKeys[1] will contain the value for 'Lastname' and e._currentRowKeys[2] will contain the value for 'Firstname' 'In addition, the 'e' object contains: 'e.tmpl - the Component definition 'e.session - session variables 'e.__si - state information that is stored in a hidden field in the component. 'e.rtc - holds runtime calculations that are performed when component is executing. 'If you set certain properties in 'e._set' then the appropriate Javascript code will be automatically generated in the Ajax response 'Examples: 'e._set.lastname.value = "Smith" --- will set the value of the 'Lastnme' field in the current row to "Smith" 'e._set.lastname.style = "color: red;" --- will set the style attribute for the 'Lastname' field in the current row. 'e._set.lastname.className = "NewClassName" --- will set the ClassName attribute of the 'Lastname' field in the current row. 'e._set.firstname.style.color = "red" --- will set the style.color attribute to 'Red' (preserving all other style attributes that had been set) 'e._set.firstname.style.fontSize = "20pt" -- will set the style.fontSize attribute to '20pt' (preserving all other style attributes that had been set) (Important: the name of the style attribute is case-sensitive) 'Note: 'Assume your callback submitted data from the 'Grid' part, row 3: 'e._set.lastname.value = "Smith" gets converted to this Javascript code: '{grid.object}._setValue('G','LASTNAME',3,'' + 'Smith',true);' and this code is automatically added to the Ajax response. 'Note: 'In addition to 'e._set', you can set properties of the 'e._setElement', 'e._setGridElement' and 'e._setRow' objects. 'Examples: 'e._setRow3.lastname.value = "Smith" 'e._setRow_1.firstname.value = "John" --- sets the value in the first New Record row 'e._setElement.DIV1.value = "Some text" --- sets the innerHTML of DIV with the id of 'DIV1' 'e._setGridElement.SPN2.style.color = "Red" ---- sets style properties of a SPAN with id of '{grid.componentname}.SPN2' 'example code: 'Return a Javascript command 'lowLevelDelete = "alert('You submitted a value of: " + js_escape(e._currentRowDataNew.lastname) + "');" end function function DeleteWithPrompt as c (e as p) dim currentState as c 'note - since this grid is NOT editable, by default data from the current row is NOT submitted 'when the callback is made (the Primary Key is submitted). 'So, e._currentRowData will be empty, UNLESS you check the 'compute current row data' checkbox 'when defining the ajax callback in action javascript currentState = e._currentRowDataNew.bill_state_region 'ok, now that we have the state value for the current row, let's do an AlphaDAO query to see how 'many customers there are in this state dim cn as sql::connection dim cs as c 'get the connection string that is defined in this Grid component cs = e.tmpl.cs.connectionString dim flag as l flag = cn.open(cs) if flag = .f. then dim msg as c msg = "Could not connect to database. Error reported was: " + cn.CallResult.text 'we need to encode this for javascript since the message will be sent back to the browser for display 'js_escape() encodes ' as \' and crlf as \n msg = js_escape(msg) dim jscmd as c 'create the javascript command to send back to the browser. this command will 'display a javascript alert box. 'at this point we are done, so exit the function and return jscmd. 'note that in xbasic the way a function returns a value is you set the function name to the value 'you want to return. jscmd = "alert('" + msg + "');" lowLevelDelete = jscmd exit function end if dim sql as c 'note that the sql uses an argument in the where clause. arguments start with : sql = "select count(*) from customer where bill_state_region = :whatState" dim args as sql::arguments 'set the value of the 'whatState' argument. args.add("whatState",currentState) flag = cn.Execute(sql,args) if flag = .f. then 'there was an error - close the connection and exit cn.Close() dim msg as c msg = "Could execute count query. Error reported was: " + cn.CallResult.text msg = js_escape(msg) dim jscmd as c jscmd = "alert('" + msg + "');" lowLevelDelete = jscmd exit function end if dim rs as sql::resultset rs = cn.ResultSet dim recordCount as n 'since we executed a count query, the resultset will only have one column - which holds the count 'read the data in the first (and only) column of the resultset recordCount = rs.data(1) 'the arbitrary rule I have is that you can't delete a record if there are fewer than '5 records from the same state if recordCount < 5 then cn.close() dim msg as c msg = "You can't delete this record because we have an arbitrary rule that says you can only delete a record if more than 5 records from the same state exist." msg = js_escape(msg) dim jscmd as c jscmd = "alert('" + msg + "');" lowLevelDelete = jscmd exit function end if 'ok, if we get to this point, then it is ok to delete the record. dim jscmd as c jscmd = <<%js% var answer = confirm('OK to delete this record?'); if(answer == true) { {grid.Object}.ajaxCallback('G',{Grid.RowNumber},'DoDelete','','_getData=true'); } else { alert('Record will not be deleted'); } %js% DeleteWithPrompt = jscmd end function function DoDelete as c (e as p) currentState = e._currentRowDataNew.bill_state_region dim cn as sql::connection dim cs as c cs = e.tmpl.cs.connectionString dim flag as l flag = cn.open(cs) if flag = .f. then dim msg as c msg = "Could not connect to database. Error reported was: " + cn.CallResult.text msg = js_escape(msg) dim jscmd as c jscmd = "alert('" + msg + "');" DoDelete = jscmd exit function end if dim args as sql::arguments dim pkValue as c pkValue = e._currentRowKeys[1] dim sqldelete as c sqldelete = "delete from customer where customer_Id = :whatCustomerId" args.add("whatCustomerId", convert_type(pkValue,"N")) flag = cn.Execute(sqldelete,args) if flag = .f. then 'there was an error - close the connection and exit cn.Close() dim msg as c msg = "Could not delete record. Error reported was: " + cn.CallResult.text msg = js_escape(msg) dim jscmd as c jscmd = "alert('" + msg + "');" DoDelete = jscmd exit function end if dim rowsAffected as n rowsAffected = cn.affectedrows() if rowsAffected = 0 then 'no records were actually deleted cn.Close() dim msg as c msg = "Record to delete was not found. No records were deleted." msg = js_escape(msg) dim jscmd as c jscmd = "alert('" + msg + "');" DoDelete = jscmd exit function end if dim jscmd as c = "" jscmd = jscmd + "{grid.object}.refresh();" 'let's also add an optional message jscmd = jscmd + "alert('Record was deleted');" doDelete = jscmd end function CHiddenCShow/Hide QBE RowC FieldsOnlyCz
Please wait...
C A5WindowLockC SinglePageC LinkedGridsCj
Working...
C MultipleCTable - Vertical LayoutCDetailCSearch,Grid,DetailViewCCollapse GridCopenCSun,Mon,Tue,Wed,Thu,Fri,SatCVJanuary,February,March,April,May,June,July,August,September,October,November,DecemberCTodayC*images/$$application.ms.excel.png.a5imageCExport data in Grid to ExcelC{PageNumber} of {PageCount}C {PageNumber}CPrevCNextC,{css_path_reference}/{a5_style}/FirstOn.pngC-{css_path_reference}/{a5_style}/FirstOff.pngC+{css_path_reference}/{a5_style}/PrevOn.pngC,{css_path_reference}/{a5_style}/PrevOff.pngC+{css_path_reference}/{a5_style}/NextOn.pngC,{css_path_reference}/{a5_style}/NextOff.pngC+{css_path_reference}/{a5_style}/LastOn.pngC,{css_path_reference}/{a5_style}/LastOff.pngCSubmitCSubmit changes?CAllRowsC AlwaysShownC New RecordsC CheckboxC0Field '{Fieldlabel}', Value '{Value}' : {Error}C0Click the 'Back' button and correct the errors.CRowCErrorCBottomCAutoCIn GridCTextboxC Search for:C WildcardNCSelwynTu%PTTzw%LCGrid.PropertiesN@C]C:\a5V10\Packages\AJAX_webComponents.WebProjects\fileUpload.WebProject\lowLevelDelete.a5wcmpC![PathAlias.ADB_Path] [mydata] C$C:\a5V10\Packages c:\alphasports C@[PathAlias.ADB_Path]|C:\a5V10\Packages [mydata]|c:\alphasportsC{class.FreeStandingButton}={grid.style}Button {class.FreeStandingHyperlink}={grid.style}NavigatorLink {class.GridData}={grid.style}{Alt}DataTD C*fff73908-8a17-4181-b015-22c2e5d13b99 C %str%> > > C'7dde31ba-f6b7-49bf-bac7-f78ee75d9802 C %str%> > > CC:\a5V10\PackagesC C:\a5V10generatedHtmlOtherPropertiesSecurityModelGUIDDateFormatOnServerDoesNotMatchClientDateFormatOnClientclientSideDateFormatflagTreeViewGridflagTreeViewDVcomponentTypeXbasicdatasourceTypecomponentNamemdb_or_csmdb_filenameconnection_typeconnection_nameconnection_stringbase_ontable_nametable_aliassql_selectfilterorderdatabase_typeprimary_keysurrogate_primary_keyReadOnlySQLIsStoredProcedureFieldInfoview_deffieldsflag_uniqueSQLflagSQLModifiedPrimaryKeyDataSQLBuilder[1]ArgumentsPromptTextAboveArgumentsPagequery_adoSurrogatePrimaryKeyDatatable_typeidentitySequenceNamequery_cstypecalcfieldstablenametablealiasDirectionflags_UniqueViewFieldsFieldMapa_tablesJoinInfoPrimaryKeyquery_dbfeditableTableInLineStyleTableAttributesgriddummyfieldnameCalcExpressionShowExpressionEnableExpressionHasValidationRulesHasValidationXbasicTitletabControlPropsTabControlIDTabPaneIDAjaxCallBackonChangeonBeforeChangeonRightClickonDynamicLoadJSpaneWidthpaneHeightclassNameselectedClassNamedisabledClassNamepaneClassNameshowdisabledshowHideExpressionenableExpressionTabPaneuseModernTabsIDTypeTabPositionAccordionTypeInitialPaneInitialOpenAccordionPanesBreakTypeTabControlFrameTitleStyleClassLegendBordershowHideEnabledopenIconclosedIconinitialStateframepaneclassframepanestyleFrameContainerStaticTextLinkedGridDefinitionImageDefinitionclassstyleAltDynamicImageButtonTextButtonHyperlinkTextHyperlinkHorizontalVerticalAboveBelowLeftRightSpacernColsColumnInlineStyleRowInlineStyleLayoutonclickondblclickonmousedownonmouseuponmouseoveronmousemoveonmouseoutonkeypressonkeydownonkeyuponchangeonbluronselectonfocusjavascriptjavascriptDeclarationsRowjavascriptDeclarationsGlobalclientSideXbasicFunctionscontroltypeValidationRulesValidationXbasicEnable_ClientSideValidationValidate_OnBlurRangeSearchFromLabelToLabelKeywordSearchKeywordSearchFieldsSearch_StyleSearchInLineStyleLabelInlineStyleTextBlurbHeadingImageNameIsHyperLinkhyperlinkTargethyperlinkTargetFrameImagePathImagereadonlyDateFormatSwitchYearUseComboBoxesLowYearHighYearcalendarCustomSizeMaxLengtherrorinlinestylestylefieldiferrorIsPasswordHasLookupTextBoxhasWatermarktextWatermarkhasClientSideFormatDefinitionclientSideFormatLookuprowscolsRichTextEditorheightwidthdisplayisPopupRichTextTextAreaconnectionStringparameter_stringsqladocschoicesdatasourceAdditionalChoicesPreAdditionalChoicesPostDataSourceVariableNamedisplayValueFieldstoredValueFieldtabledbfinlinestylemaxchoicesNotInListRuleorientationradiobuttoninitial_valueCheckBoxuse_saved_connection_stringsaved_connection_stringselectStylehasCascadingChoicesparentControlnoSelectionDisplayValuenoChoicesDisplayValuenoChoicesFoundautoSubmitSearchdropdownboxadvancedButtonDisplayIconNumberDatePickerHideFreeFormLayoutFreeFormTemplateFreeformSearchheadingheading_leftLabelInLineStyleLabelPositionStyleLabelIfFieldErrorErrorLabelInLineStyleSecurityLevelSecurityGroupsCanSortsortcolumnValidateOnClickservereventsDisplayExpressionStaticImageStaticImageInlineStyleStaticImageAltAlternateImageControlComputedAddresstargetFrameOrWindowClearParametersDisplayTypeajaxWindowTypeajaxWindowTitleajaxWindowHeightajaxWindowWidthajaxWindowisResizableajaxWindowWorkingMessageajaxWindowWorkingMessageIconajaxWindowRefreshGridOnCloseajaxWindowPositionAttributetargetDIVidtargetDIVcanHidetargetDIVHideHyperlinktargetDIVIframeStylelinkBaseFieldExpressionDisplayFormatDisplayUnformatConditionalStyleConditionalStyleLevelClientSideConditionalStyleClientSideConditionalStyleLevelQBEDisableQBEInlineStyleUpdateableTreatBlankAsNullUpdateSecurityLevelUpdateSecurityGroupsTableAliascanBeUsedInWhereClausenativeTypeautoincrementFieldToUpdatehasdisplayformattotalcountaverageminmaxStdDevVarFirstLastsummaryBubbleHelpBubbleHelpLabelSourceAliasPortableTypedecvarnamedisplayODdisplayODFlatscopexbasicFunctionstmplTxtComputedtmplTxt[2][3][4]FieldnameControlIDlayoutallowImageUploadImageUploadRelativePathImageUploadCustomizationallowFileUploadFileUploadRelativePathFileUploadCustomizationSearchExpression[5][6]a_fieldsfield_indexlinkfieldhas_DetailViewLayoutColumnsAddNewLinkLabelSaveRecordButtonLabelDeleteRecordButtonLabelAddRecordButtonLabelHasTitleshow_row_labelsShow_Update_CommandsExecute_Update_Commandsallow_updateallow_insertallow_deletevalidateFieldsSettingNumber_Of_Insert_Rowshas_Cancel_buttoncancel_button_textclose_button_textsave_confirm_before_submitdelete_confirm_before_submitadd_confirm_before_submitsave_confirm_before_submit_messagedelete_confirm_before_submit_messageadd_confirm_before_submit_messagecheck_for_write_conflictswrite_conflict_check_typesave_original_valuesDelete_TargetPageSave_TargetPageAdd_TargetPageInsertSecurityLevelDeleteSecurityLevelInsertSecurityGroupsDeleteSecurityGroupsiconcontrol_classnameerror_classnamecontrol_hover_classnameerror_hover_classnamefield_error_styleRefreshRowMethodshow_row_errors_in_popuprow_errors_window_titlerow_errors_window_styleFocusAfterFullPageRefreshForInsertFocusAfterFullPageRefreshForUpdateFocusAfterFullPageRefreshForDeleteEditable_GridRow_Options_StyleRefreshRowOnDirtyRowEditStyleLazyEditeditHideGridIfDetailViewIsVisibleOnlyShowOnRequestHasCloseLinkCloseDetailViewLinkLabelCloseAfterSubmitCanClosePositionshowRecordNavigatorLinksButtonsActionButtonsToolbarPopulateUsingJavaScriptUseSimpleStylesSimpleStyleModescrollIntoViewdisplayStylewindowDragOpacityPopupWindowTitleOpenMethodToggletotal_records_rowShowNewRecordIfNoRecordsInQueryDetailViewdetailfieldsTopBottomsearchGridEditRegionWatchEvents_DetailViewtoolbarjavascriptDialogscustomizationStringHasSearchPartHTML_Template_sourcetitletitle_when_hiddenshow_titlesearch_button_labelform_methodinclude_sorting_listboxsorting_listbox_label_positionpromptpromptInLineStylefieldname_promptuse_column_headingsorder_promptorder_choiceslistboxcustomSortDefinitioninclude_records_per_page_listboxrecords_per_page_label_positionvalue_promptrecords_per_pagecombine_criteria_usingallow_qbf_styleshow_single_search_fieldkeyword_labelMake_search_button_activehas_Clear_linkClear_link_LabelTargetPageEnableShowHideInitialStateHideGridWhenNoActiveSearchGridHTMLWhenHiddenembedInGridPartembedInGridPositionhasFreeformLayoutshowHideEmbeddedSearchIconshowHideEmbeddedSearchBubbleHelpshowSearchIconsInRowSelectorsearchIconBubbleHelpclearSearchIconBubbleHelpsearchIconclearSearchIconembeddedembeddedStylefreeformTemplateshowHideAnimationtoolbarPositionWatchEvents_SearchdisplayODtreesearchFieldssearchField_indexBeforeSearchAfterSearchCanSearchBeforeValidateExistingRecordsBeforeValidateNewRecordsAfterUpdateRecordsCanUpdateRecordCanDeleteRecordCanInsertRecordOnExpandRowonPageRedirectAfterUpdateRecordAfterDeleteRecordAfterInsertRecordOnSearchPartFilterComputeOnGridInitializeOnGridExecuteOnGridPartRenderOnBeforeExistingRowsRenderOnExistingRowRenderOnAfterExistingRowsRenderOnTitlesRenderOnSummarySectionRenderOnBeforeNewRowsRenderOnNewRowRenderOnAfterNewRowsRenderOnInitialValueCalculateOnDetailViewRenderShowRowExpanderIconOnWriteConflictOnSQLExecuteErroronBeforeSQLCommandExecuteonAfterSQLCommandExecuteeventIndexDetailLayoutColumnsstyle_nameTabLayoutPropertiesPreCalcModeFontSizeoverrideStylesForJavascriptObjectsoverrideStyleNamealternate_bandsconditionalStyleclientSideConditionalStyleodd_band_sizeeven_band_sizealternate_column_bandsodd_column_band_sizeeven_column_band_sizesuppress_empty_rowshas_row_separatorshow_column_titlessuppress_titles_if_no_recordssort_stylereset_page_number_when_sortingRepeatingColumnssnakingtotal_records_row_positiongrid_layout_styleshow_row_selectorgrid_layout_template_computation_methodNo_records_messagegrid_is_editableAdd_Records_OnlyShow_Add_Records_Confirmation_MessageAdd_Records_Confirmation_Message_TemplatelabelLblInlineStyleRowOrderShowOnLastPageOnlySuppressHasRowSeparatorsHasNewRecordsTitleNewRecordsTitleHasExistingRecordsTitleExistingRecordsTitlerow_separatorhighlight_row_onHoverhighlight_row_onSelecthasRecordsPerPageSelectorRecordsPerPageChoicesRecordsPerPageSelectorTemplatehas_alphabet_button_search_barsearch_fieldpositionhas_ALL_optionALL_LabelhasNumericButtonsSearchBarTypecustomButtonDefinitionalphabet_buttonOnRowDoubleClickXbasicFunctionDeclarationsClientSideXbasicFunctionDeclarationsJavaScriptFunctionDeclarationshas_qbe_rowinitial_displaytoggleQBERowHyperlinkTextqbehasRowExpandColumnhasLinkedContentlinkedContentDefinitionlockWindowlockWindowTextlockWindowClassNamelinkedContenthasExternalNavigatorsexternalNavigatorsDefinitionhasSelectedRowColumnhasCheckboxSelectColumnCheckboxSelectTypeLinkGridDefinitionWorkingMessageModeExpandFirstRowOnLoadRowExpandAdditionalGridStylesLocalCssCSSLinkedFilesJavaScriptLinkedFilesuseMasterTemplateMasterTemplateStyleMasterLayoutTemplateMasterLayoutTemplateJavascriptPaneLabelAccordionStyleInitialOpenPanesMasterLayoutCanCollapseGridOpenIconClosedIconContainerStyleContainerClassCollapseBarrowEventsonRowBluronRowFocusonRowRenderonDetailViewRendercanSubmitRowafterCommitRowonDetailViewEditModeChangeonEditModeChangeafterCancelEditsafterDetailViewCancelEditsgridEventsgridToolbarTemplategridToolbarTemplateEditableaexFilesa5wIncludeFilesWatchEvents_GridhonorDBFFieldRuleslanguageDefinitionslinkedResourcesonlyIncludeSelectedFieldsInQuerydayNamesmonthNamesfirstDayOfWeektodayButtonTextcloseButtonTextdatePickerToolbarActionButtonsiconMapOverridespublishedServerVariableshasExportButtonExportButtonIconExportButtonHelpgridToolbarShow_disabled_controlsUse_ImagesShow_Page_CountPage_Numbering_StylePagesTemplate_w_PageCountPagesTemplate_wout_PageCountHas_First_ButtonHas_Prev_ButtonHas_Next_ButtonHas_Last_ButtonNumber_of_page_linksFirst_LabelPrev_LabelNext_LabelLast_LabelJustifySuppressIfOnlyOnePagesuppress_recNavBar_if_no_recordsFirst_on_Image_nameFirst_off_Image_namePrev_on_Image_namePrev_off_Image_nameNext_on_Image_nameNext_off_Image_nameLast_on_Image_nameLast_off_Image_nameRecNavnumber_of_insert_rowsdelete_checkbox_labelsubmit_button_textcancel_button_inlinestylesubmit_button_inlinestyleconfirm_before_submitconfirm_before_submit_messageRefreshRowOnFocusNewRecordsEditStyleHideNewRecordsAfterInsertNewRecordsButtonLabelDeleteRecordControlHasRowStatusColumnOneEditableRowAtATimeabortGridUpdateIfAnyRowHasErrorValidationSettingsErrorTemplateValidationSettingsMessageValidationErrorsRowColumnTitleValidationErrorsErrorColumnTitleOnlyValidateEditedFieldsShowNewRecordsOnLastPageOnlyAddNewRecordRowsPositionautoNumberColumnLabelHasQuickSearchQuickSearchPositionQuickSearchAlignFieldToSearchControlTypeAutoSubmitlabelInLineStyleHasfreeFormLayoutfreeFormLayoutSearchButtonLabelAllowQBFStyleSearchSearchStyleHeightSelectStyleOrientationdisplayValueFieldTypeHasShowAllButtonShowAllButtonLabelInitialSelectionDefaultFieldToSearchQuickSearchdescriptioncreatedByLastUpdatedByDateCreatedDateUpdatedCommentsinfoBuilderVersiongridEventsJavascript_hasCodecurrent_pane_treehasActionButtonsAjaxOnversionNumbercomponentFilenameSecurityModealiasalias_expandedalias_aliasExpandederrorPAliases_row_onHoverflagUseSimpleStylesclassMapfatalErroractionGuidscriptMetaDataa_actionJavascriptADB_PATHEXE_PATH