Angular - disable any input control

 

<input [attr.disabled]="disabled ? '' : null"/>

set to 'null' in order to NOT add the attr to the element

Angular - filter array to retrun the first object

Use the below code to filter the array to return only the first object

array.find(data => data.item_id == 1)

SSRS - make first letter of every word in string to uppercase

Call the below function:

 

=StrConv(Fields!FieldName.Value, vbProperCase)

MVC razor - radio button click by label

Wrap each radio button and associated label text inside a <label> element:
<label> @Html.RadioButtonFor("gender", "Male") Male </label>
<label> @Html.RadioButtonFor("gender", "Female") Female </label>

JQuery - get radio button value

<!DOCTYPE html>

<html>

<head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

<script>

$(document).ready(function(){

    

$("input[name='gender']").click(function(){

         var radioValue = $("input[name='gender']:checked").val();

            if(radioValue){

                alert("Your are a - " + radioValue);

$(radioValue).css("background-color","yellow");

            }

        });

 

 

 

});

</script>

</head>

<body>

 

<h1>Welcome to My Homepage</h1>

  <input type="radio" name="gender" id="gender" value=".bbb"> Male<br>

  <input type="radio" name="gender" id="gender" value=".bbb,.intro"> Female<br>

  <input type="radio" name="gender" id="gender" value="other"> Other

<p class="intro xxx bbb">My name is Donald.</p>

<p>I live in Duckburg.</p>

 

<div class="intro">My name is Dolly.</div>

<p>I live in Duckburg.</p>

 

</body>

</html>

Pass datetime parameters to openrowset/query

DECLARE @sqlCommand varchar(1000)
DECLARE @StartDate datetime
DECLARE @EndDate datetime
DECLARE @local int
SET @StartDate = '20100101'
SET @EndDate = '20110101'
SET @local = 1
SET @sqlCommand = 'SELECT * FROM OPENROWSET(''SQLNCLI'',''server=servername;trusted_connection=yes'',''SET FMTONLY OFF exec procname ''''' + convert(varchar(10),@StartDate,112) + ''''',''' + convert(varchar(10),@EndDate,112) + ''''',' + cast(@local as varchar(10)) + ''')'

PRINT @sqlCommand
--EXEC (@sqlCommand)

Iterate through rows of dataset in report's custom code

The ideal is to "transform" the data set into a multivalued parameter (or if you need several fields, transform it in multiple multivalued parameters).

The multivalued Report Parameter must have the following characteristics:

Hidden = True

Allow Multiple Values = True

Available Values tab:

Chose the desired dataset. Select the searchable id as Value id, and the field you want to expose as Label Field.

Default Values Tab - Get Values from a Query.

Choose the same Dataset as choosen in the available Values Tab.

Value Field the same you choose for value id.

Set the parameter to never refresh (or it will be loading the data from each iteraction of another parameter).

Now, the idea is make this Parameter "searchable". From this point you exposed the Dataset as an array in the Multi valued Parameter.

Now in a custom code insert the following code:

function GetDataSetLabelFromValue( id as integer) as String

dim i as integer

i = 0

for i = 1 to Report.Parameters!YourParameter.Count()

if Report.Parameters!YourParameter.Value(i) = id then

GetDataSetLabelFromValue = Report.YourParameter!ReportParameter1.Label(i)

Exit For

End if

next i

End Function

 

 

SQL - Query xml attribute

 

SELECT TOP 100 s.owner_id, mpln_key, mpln_member, mpln_owner, pln_key , pln_cb_id ,

asset_mix.value('(/asset_mix/mem_plan/@market_value)[1]','decimal(18,2)') as market_value,

asset_mix.value('(/asset_mix/mem_plan/@plan_allocate_rating)[1]','varchar(2)') as plan_allocate_rating,

asset_mix.value('(/asset_mix/mem_plan/asset_mix_result[@investment_type_EN="Short Term (GTD Investments)"]/@investment_type_EN)[1]','varchar(30)') as investment_type_EN,

asset_mix.value('(/asset_mix/mem_plan/asset_mix_result[@investment_type_EN="Short Term (GTD Investments)"]/@asset_allocation)[1]','varchar(30)') as asset_allocation,

asset_mix.value('(/asset_mix/mem_plan/asset_mix_result[@investment_type_EN="Global Equity"]/@investment_type_EN)[1]','varchar(30)') as investment_type_EN,

asset_mix.value('(/asset_mix/mem_plan/asset_mix_result[@investment_type_EN="Global Equity"]/@asset_allocation)[1]','varchar(30)') as asset_allocation,

asset_mix.value('(/asset_mix/mem_plan/asset_mix_result[@investment_type_EN="Canadian Equity"]/@investment_type_EN)[1]','varchar(30)') as investment_type_EN,

asset_mix.value('(/asset_mix/mem_plan/asset_mix_result[@investment_type_EN="Canadian Equity"]/@asset_allocation)[1]','varchar(30)') as asset_allocation,

asset_mix.value('(/asset_mix/mem_plan/asset_mix_result[@investment_type_EN="Bonds"]/@investment_type_EN)[1]','varchar(30)') as investment_type_EN,

asset_mix.value('(/asset_mix/mem_plan/asset_mix_result[@investment_type_EN="Bonds"]/@asset_allocation)[1]','varchar(30)') as asset_allocation

 

from [DC4Reports].[dbo].[member_plan_wrapper_extraction] as s

where owner_id= 3620

SQL -Update XML column

 

declare @new_rating int

set @new_rating = 0

 

 

UPDATE [member_plan_wrapper_extraction]

SET asset_mix.modify('replace value of (/asset_mix/mem_plan/@plan_allocate_rating)[1] with sql:variable("@new_rating") ')

WHERE owner_id=@owner_id

and mpln_member = @mpln_member

and mpln_owner = @mpln_owner

and pln_cb_id=@pln_cb_id ;

SQL - Query to Find Column From All Tables of Database

 SELECT t.name AS table_name,
 SCHEMA_NAME(schema_id) AS schema_name,
 c.name AS column_name
 FROM sys.tables AS t
 INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
 WHERE c.name LIKE '%sp_id%'
 ORDER BY schema_name, table_name;